Use static QRegularExpression
This commit is contained in:
@@ -314,8 +314,8 @@ QString CXXDemangle(const QString &mangled_function) {
|
|||||||
QString LinuxDemangle(const QString &symbol);
|
QString LinuxDemangle(const QString &symbol);
|
||||||
QString LinuxDemangle(const QString &symbol) {
|
QString LinuxDemangle(const QString &symbol) {
|
||||||
|
|
||||||
QRegularExpression regex(QStringLiteral("\\(([^+]+)"));
|
static const QRegularExpression regex_symbol(QStringLiteral("\\(([^+]+)"));
|
||||||
QRegularExpressionMatch match = regex.match(symbol);
|
QRegularExpressionMatch match = regex_symbol.match(symbol);
|
||||||
if (!match.hasMatch()) {
|
if (!match.hasMatch()) {
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1497,7 +1497,8 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
|
|||||||
album_info.art_embedded = query.Value(6).toBool();
|
album_info.art_embedded = query.Value(6).toBool();
|
||||||
|
|
||||||
const QString art_automatic = query.Value(7).toString();
|
const QString art_automatic = query.Value(7).toString();
|
||||||
if (art_automatic.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
|
static const QRegularExpression regex_url_schema(QStringLiteral("..+:.*"));
|
||||||
|
if (art_automatic.contains(regex_url_schema)) {
|
||||||
album_info.art_automatic = QUrl::fromEncoded(art_automatic.toUtf8());
|
album_info.art_automatic = QUrl::fromEncoded(art_automatic.toUtf8());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1505,7 +1506,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString art_manual = query.Value(8).toString();
|
const QString art_manual = query.Value(8).toString();
|
||||||
if (art_manual.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
|
if (art_manual.contains(regex_url_schema)) {
|
||||||
album_info.art_manual = QUrl::fromEncoded(art_manual.toUtf8());
|
album_info.art_manual = QUrl::fromEncoded(art_manual.toUtf8());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1163,7 +1163,8 @@ QString CollectionModel::SortText(QString text) {
|
|||||||
else {
|
else {
|
||||||
text = text.toLower();
|
text = text.toLower();
|
||||||
}
|
}
|
||||||
text = text.remove(QRegularExpression(QStringLiteral("[^\\w ]"), QRegularExpression::UseUnicodePropertiesOption));
|
static const QRegularExpression regex_not_words(QStringLiteral("[^\\w ]"), QRegularExpression::UseUnicodePropertiesOption);
|
||||||
|
text = text.remove(regex_not_words);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
|
|||||||
@@ -388,7 +388,8 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filen
|
|||||||
void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction) {
|
void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction) {
|
||||||
|
|
||||||
// Run each command
|
// Run each command
|
||||||
QStringList commands = schema.split(QRegularExpression(QStringLiteral("; *\n\n")));
|
static const QRegularExpression regex_split_commands(QStringLiteral("; *\n\n"));
|
||||||
|
QStringList commands = schema.split(regex_split_commands);
|
||||||
|
|
||||||
// We don't want this list to reflect possible DB schema changes, so we initialize it before executing any statements.
|
// We don't want this list to reflect possible DB schema changes, so we initialize it before executing any statements.
|
||||||
// If no outer transaction is provided the song tables need to be queried before beginning an inner transaction!
|
// If no outer transaction is provided the song tables need to be queried before beginning an inner transaction!
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void LocalRedirectServer::WriteTemplate() const {
|
|||||||
QString page_data = QString::fromUtf8(page_file.readAll());
|
QString page_data = QString::fromUtf8(page_file.readAll());
|
||||||
page_file.close();
|
page_file.close();
|
||||||
|
|
||||||
QRegularExpression tr_regexp(QStringLiteral("tr\\(\"([^\"]+)\"\\)"));
|
static const QRegularExpression tr_regexp(QStringLiteral("tr\\(\"([^\"]+)\"\\)"));
|
||||||
qint64 offset = 0;
|
qint64 offset = 0;
|
||||||
forever {
|
forever {
|
||||||
QRegularExpressionMatch re_match = tr_regexp.match(page_data, offset);
|
QRegularExpressionMatch re_match = tr_regexp.match(page_data, offset);
|
||||||
|
|||||||
@@ -240,8 +240,10 @@ void AlbumCoverChoiceController::SaveCoverToFileManual(const Song &song, const A
|
|||||||
}
|
}
|
||||||
initial_file_name = initial_file_name + QLatin1Char('-') + (song.effective_album().isEmpty() ? tr("unknown") : song.effective_album()) + QLatin1String(".jpg");
|
initial_file_name = initial_file_name + QLatin1Char('-') + (song.effective_album().isEmpty() ? tr("unknown") : song.effective_album()) + QLatin1String(".jpg");
|
||||||
initial_file_name = initial_file_name.toLower();
|
initial_file_name = initial_file_name.toLower();
|
||||||
initial_file_name.replace(QRegularExpression(QStringLiteral("\\s")), QStringLiteral("-"));
|
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||||
initial_file_name.remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption));
|
initial_file_name.replace(regex_whitespaces, QStringLiteral("-"));
|
||||||
|
static const QRegularExpression regex_invalid_fat_characters(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
initial_file_name.remove(regex_invalid_fat_characters);
|
||||||
|
|
||||||
QString save_filename = QFileDialog::getSaveFileName(this, tr("Save album cover"), GetInitialPathForFileDialog(song, initial_file_name), tr(kSaveImageFileFilter) + QStringLiteral(";;") + tr(kAllFilesFilter));
|
QString save_filename = QFileDialog::getSaveFileName(this, tr("Save album cover"), GetInitialPathForFileDialog(song, initial_file_name), tr(kSaveImageFileFilter) + QStringLiteral(";;") + tr(kAllFilesFilter));
|
||||||
|
|
||||||
|
|||||||
@@ -225,11 +225,13 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
|||||||
for (QString uri : std::as_const(uris)) {
|
for (QString uri : std::as_const(uris)) {
|
||||||
|
|
||||||
// gphoto2 gives invalid hostnames with []:, characters in
|
// gphoto2 gives invalid hostnames with []:, characters in
|
||||||
uri.replace(QRegularExpression(QStringLiteral("//\\[usb:(\\d+),(\\d+)\\]")), QStringLiteral("//usb-\\1-\\2"));
|
static const QRegularExpression regex_url_usb(QStringLiteral("//\\[usb:(\\d+),(\\d+)\\]"));
|
||||||
|
uri.replace(regex_url_usb, QStringLiteral("//usb-\\1-\\2"));
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
|
|
||||||
if (uri.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
|
static const QRegularExpression regex_url_schema(QStringLiteral("..+:.*"));
|
||||||
|
if (uri.contains(regex_url_schema)) {
|
||||||
url = QUrl::fromEncoded(uri.toUtf8());
|
url = QUrl::fromEncoded(uri.toUtf8());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -243,7 +245,8 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
|||||||
url.setScheme(QStringLiteral("ipod"));
|
url.setScheme(QStringLiteral("ipod"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression device_re(QStringLiteral("usb/(\\d+)/(\\d+)"));
|
static const QRegularExpression regex_usb_digit(QStringLiteral("usb/(\\d+)/(\\d+)"));
|
||||||
|
QRegularExpression device_re(regex_usb_digit);
|
||||||
QRegularExpressionMatch re_match = device_re.match(unix_device);
|
QRegularExpressionMatch re_match = device_re.match(unix_device);
|
||||||
if (re_match.hasMatch()) {
|
if (re_match.hasMatch()) {
|
||||||
QUrlQuery url_query(url);
|
QUrlQuery url_query(url);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
QString hostname = url.host();
|
QString hostname = url.host();
|
||||||
// Parse the URL
|
// Parse the URL
|
||||||
QRegularExpression host_re(QStringLiteral("^usb-(\\d+)-(\\d+)$"));
|
static const QRegularExpression host_re(QStringLiteral("^usb-(\\d+)-(\\d+)$"));
|
||||||
|
|
||||||
unsigned int bus_location = 0;
|
unsigned int bus_location = 0;
|
||||||
unsigned int device_num = 0;
|
unsigned int device_num = 0;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ QUrl AzLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
|||||||
|
|
||||||
QString AzLyricsComLyricsProvider::StringFixup(const QString &text) {
|
QString AzLyricsComLyricsProvider::StringFixup(const QString &text) {
|
||||||
|
|
||||||
return Utilities::Transliterate(text).remove(QRegularExpression(QStringLiteral("[^\\w0-9\\-]"))).toLower();
|
static const QRegularExpression regex_words_numbers_and_dash(QStringLiteral("[^\\w0-9\\-]"));
|
||||||
|
return Utilities::Transliterate(text).remove(regex_words_numbers_and_dash).toLower();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,12 @@ QUrl ElyricsNetLyricsProvider::Url(const LyricsSearchRequest &request) {
|
|||||||
|
|
||||||
QString ElyricsNetLyricsProvider::StringFixup(const QString &text) {
|
QString ElyricsNetLyricsProvider::StringFixup(const QString &text) {
|
||||||
|
|
||||||
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]"));
|
||||||
|
static const QRegularExpression regex_duplicate_whitespaces(QStringLiteral(" {2,}"));
|
||||||
|
|
||||||
return Utilities::Transliterate(text)
|
return Utilities::Transliterate(text)
|
||||||
.replace(QRegularExpression(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]")), QStringLiteral("_"))
|
.replace(regex_illegal_characters, QStringLiteral("_"))
|
||||||
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
|
.replace(regex_duplicate_whitespaces, QStringLiteral(" "))
|
||||||
.simplified()
|
.simplified()
|
||||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|||||||
@@ -156,15 +156,21 @@ QString HtmlLyricsProvider::ParseLyricsFromHTML(const QString &content, const QR
|
|||||||
if (!lyrics.isEmpty()) {
|
if (!lyrics.isEmpty()) {
|
||||||
lyrics.append(QLatin1Char('\n'));
|
lyrics.append(QLatin1Char('\n'));
|
||||||
}
|
}
|
||||||
|
static const QRegularExpression regex_html_tag_a(QStringLiteral("<a [^>]*>[^<]*</a>"));
|
||||||
|
static const QRegularExpression regex_html_tag_script(QStringLiteral("<script>[^>]*</script>"));
|
||||||
|
static const QRegularExpression regex_html_tag_div(QStringLiteral("<div [^>]*>×</div>"));
|
||||||
|
static const QRegularExpression regex_html_tag_br(QStringLiteral("<br[^>]*>"));
|
||||||
|
static const QRegularExpression regex_html_tag_p_close(QStringLiteral("</p>"));
|
||||||
|
static const QRegularExpression regex_html_tags(QStringLiteral("<[^>]*>"));
|
||||||
lyrics.append(content.mid(start_lyrics_idx, end_lyrics_idx - start_lyrics_idx)
|
lyrics.append(content.mid(start_lyrics_idx, end_lyrics_idx - start_lyrics_idx)
|
||||||
.remove(QLatin1Char('\r'))
|
.remove(QLatin1Char('\r'))
|
||||||
.remove(QLatin1Char('\n'))
|
.remove(QLatin1Char('\n'))
|
||||||
.remove(QRegularExpression(QStringLiteral("<a [^>]*>[^<]*</a>")))
|
.remove(regex_html_tag_a)
|
||||||
.remove(QRegularExpression(QStringLiteral("<script>[^>]*</script>")))
|
.remove(regex_html_tag_script)
|
||||||
.remove(QRegularExpression(QStringLiteral("<div [^>]*>×</div>")))
|
.remove(regex_html_tag_div)
|
||||||
.replace(QRegularExpression(QStringLiteral("<br[^>]*>")), QStringLiteral("\n"))
|
.replace(regex_html_tag_br, QStringLiteral("\n"))
|
||||||
.replace(QRegularExpression(QStringLiteral("</p>")), QStringLiteral("\n\n"))
|
.replace(regex_html_tag_p_close, QStringLiteral("\n\n"))
|
||||||
.remove(QRegularExpression(QStringLiteral("<[^>]*>")))
|
.remove(regex_html_tags)
|
||||||
.trimmed());
|
.trimmed());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ QUrl LetrasLyricsProvider::Url(const LyricsSearchRequest &request) {
|
|||||||
|
|
||||||
QString LetrasLyricsProvider::StringFixup(const QString &text) {
|
QString LetrasLyricsProvider::StringFixup(const QString &text) {
|
||||||
|
|
||||||
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]"));
|
||||||
|
static const QRegularExpression regex_multiple_whitespaces(QStringLiteral(" {2,}"));
|
||||||
|
|
||||||
return QString::fromLatin1(QUrl::toPercentEncoding(Utilities::Transliterate(text)
|
return QString::fromLatin1(QUrl::toPercentEncoding(Utilities::Transliterate(text)
|
||||||
.replace(QRegularExpression(QStringLiteral("[^\\w0-9_,&\\-\\(\\) ]")), QStringLiteral("_"))
|
.replace(regex_illegal_characters, QStringLiteral("_"))
|
||||||
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
|
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||||
.simplified()
|
.simplified()
|
||||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||||
.toLower()
|
.toLower()
|
||||||
|
|||||||
@@ -62,9 +62,12 @@ QUrl LyricFindLyricsProvider::Url(const LyricsSearchRequest &request) {
|
|||||||
|
|
||||||
QString LyricFindLyricsProvider::StringFixup(const QString &text) {
|
QString LyricFindLyricsProvider::StringFixup(const QString &text) {
|
||||||
|
|
||||||
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9_\\- ]"));
|
||||||
|
static const QRegularExpression regex_multiple_whitespaces(QStringLiteral(" {2,}"));
|
||||||
|
|
||||||
return Utilities::Transliterate(text)
|
return Utilities::Transliterate(text)
|
||||||
.remove(QRegularExpression(QStringLiteral("[^\\w0-9_\\- ]")))
|
.remove(regex_illegal_characters)
|
||||||
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
|
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||||
.simplified()
|
.simplified()
|
||||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|||||||
@@ -315,7 +315,8 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content_json.contains(QRegularExpression(QStringLiteral("<[^>]*>")))) { // Make sure it's not HTML code.
|
static const QRegularExpression regex_html_tag(QStringLiteral("<[^>]*>"));
|
||||||
|
if (content_json.contains(regex_html_tag)) { // Make sure it's not HTML code.
|
||||||
EndSearch(search, url);
|
EndSearch(search, url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,13 +45,17 @@ QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
|
|||||||
|
|
||||||
QString SongLyricsComLyricsProvider::StringFixup(QString text) {
|
QString SongLyricsComLyricsProvider::StringFixup(QString text) {
|
||||||
|
|
||||||
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9\\- ]"));
|
||||||
|
static const QRegularExpression regex_multiple_whitespaces(QStringLiteral(" {2,}"));
|
||||||
|
static const QRegularExpression regex_multiple_dashes(QStringLiteral("(-)\\1+"));
|
||||||
|
|
||||||
return text.replace(QLatin1Char('/'), QLatin1Char('-'))
|
return text.replace(QLatin1Char('/'), QLatin1Char('-'))
|
||||||
.replace(QLatin1Char('\''), QLatin1Char('-'))
|
.replace(QLatin1Char('\''), QLatin1Char('-'))
|
||||||
.remove(QRegularExpression(QStringLiteral("[^\\w0-9\\- ]")))
|
.remove(regex_illegal_characters)
|
||||||
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
|
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
|
||||||
.simplified()
|
.simplified()
|
||||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||||
.replace(QRegularExpression(QStringLiteral("(-)\\1+")), QStringLiteral("-"))
|
.replace(regex_multiple_dashes, QStringLiteral("-"))
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,10 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
|
|||||||
}
|
}
|
||||||
filepath = parts_new.join(QLatin1Char('/'));
|
filepath = parts_new.join(QLatin1Char('/'));
|
||||||
|
|
||||||
if (replace_spaces_) filepath.replace(QRegularExpression(QStringLiteral("\\s")), QStringLiteral("_"));
|
if (replace_spaces_) {
|
||||||
|
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||||
|
filepath.replace(regex_whitespaces, QStringLiteral("_"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!extension.isEmpty()) {
|
if (!extension.isEmpty()) {
|
||||||
filepath.append(QStringLiteral(".%1").arg(extension));
|
filepath.append(QStringLiteral(".%1").arg(extension));
|
||||||
@@ -308,7 +311,8 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
|
|||||||
else if (tag == QLatin1String("artistinitial")) {
|
else if (tag == QLatin1String("artistinitial")) {
|
||||||
value = song.effective_albumartist().trimmed();
|
value = song.effective_albumartist().trimmed();
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
value.replace(QRegularExpression(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption), QLatin1String(""));
|
static const QRegularExpression regex_the(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
value = value.remove(regex_the);
|
||||||
value = value[0].toUpper();
|
value = value[0].toUpper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,8 @@ void OSDDBus::ShowMessageNative(const QString &summary, const QString &message,
|
|||||||
|
|
||||||
QVariantMap hints;
|
QVariantMap hints;
|
||||||
QString summary_stripped = summary;
|
QString summary_stripped = summary;
|
||||||
summary_stripped = summary_stripped.remove(QRegularExpression(QStringLiteral("[&\"<>]"))).simplified();
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[&\"<>]"));
|
||||||
|
summary_stripped = summary_stripped.remove(regex_illegal_characters).simplified();
|
||||||
|
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
if (version_ >= QVersionNumber(1, 2)) {
|
if (version_ >= QVersionNumber(1, 2)) {
|
||||||
|
|||||||
@@ -48,12 +48,13 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||||||
QByteArray data = device->readAll();
|
QByteArray data = device->readAll();
|
||||||
|
|
||||||
// Some playlists have unescaped & characters in URLs :(
|
// Some playlists have unescaped & characters in URLs :(
|
||||||
QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
|
static const QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
|
||||||
qint64 index = 0;
|
qint64 index = 0;
|
||||||
for (QRegularExpressionMatch re_match = ex.match(QString::fromUtf8(data), index); re_match.hasMatch(); re_match = ex.match(QString::fromUtf8(data), index)) {
|
for (QRegularExpressionMatch re_match = ex.match(QString::fromUtf8(data), index); re_match.hasMatch(); re_match = ex.match(QString::fromUtf8(data), index)) {
|
||||||
index = re_match.capturedStart();
|
index = re_match.capturedStart();
|
||||||
QString url = re_match.captured(2);
|
QString url = re_match.captured(2);
|
||||||
url.replace(QRegularExpression(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)")), QStringLiteral("&"));
|
static const QRegularExpression regex_html_enities(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)"));
|
||||||
|
url.replace(regex_html_enities, QStringLiteral("&"));
|
||||||
|
|
||||||
QByteArray replacement = QStringLiteral("%1%2\"").arg(re_match.captured(1), url).toLocal8Bit();
|
QByteArray replacement = QStringLiteral("%1%2\"").arg(re_match.captured(1), url).toLocal8Bit();
|
||||||
data.replace(re_match.captured(0).toLocal8Bit(), replacement);
|
data.replace(re_match.captured(0).toLocal8Bit(), replacement);
|
||||||
|
|||||||
@@ -309,7 +309,9 @@ QStringList CueParser::SplitCueLine(const QString &line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let's remove the empty entries while we're at it
|
// Let's remove the empty entries while we're at it
|
||||||
return re_match.capturedTexts().filter(QRegularExpression(QStringLiteral(".+"))).mid(1, -1).replaceInStrings(QRegularExpression(QStringLiteral("^\"\"$")), QLatin1String(""));
|
static const QRegularExpression regex_entry(QStringLiteral(".+"));
|
||||||
|
static const QRegularExpression regex_exclude(QStringLiteral("^\"\"$"));
|
||||||
|
return re_match.capturedTexts().filter(regex_entry).mid(1, -1).replaceInStrings(regex_exclude, QLatin1String(""));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||||||
|
|
||||||
QString filename = filename_or_url;
|
QString filename = filename_or_url;
|
||||||
|
|
||||||
if (filename_or_url.contains(QRegularExpression(QStringLiteral("^[a-z]{2,}:"), QRegularExpression::CaseInsensitiveOption))) {
|
static const QRegularExpression regex_url_schema(QStringLiteral("^[a-z]{2,}:"), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
if (filename_or_url.contains(regex_url_schema)) {
|
||||||
QUrl url(filename_or_url);
|
QUrl url(filename_or_url);
|
||||||
song->set_source(Song::SourceFromURL(url));
|
song->set_source(Song::SourceFromURL(url));
|
||||||
if (song->source() == Song::Source::LocalFile) {
|
if (song->source() == Song::Source::LocalFile) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||||||
Q_UNUSED(playlist_path);
|
Q_UNUSED(playlist_path);
|
||||||
|
|
||||||
QMap<int, Song> songs;
|
QMap<int, Song> songs;
|
||||||
QRegularExpression n_re(QStringLiteral("\\d+$"));
|
static const QRegularExpression n_re(QStringLiteral("\\d+$"));
|
||||||
|
|
||||||
while (!device->atEnd()) {
|
while (!device->atEnd()) {
|
||||||
QString line = QString::fromUtf8(device->readLine()).trimmed();
|
QString line = QString::fromUtf8(device->readLine()).trimmed();
|
||||||
|
|||||||
@@ -27,13 +27,17 @@ const char *MusixmatchProvider::kApiKey = "Y2FhMDRlN2Y4OWE5OTIxYmZlOGMzOWQzOGI3Z
|
|||||||
|
|
||||||
QString MusixmatchProvider::StringFixup(QString text) {
|
QString MusixmatchProvider::StringFixup(QString text) {
|
||||||
|
|
||||||
|
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9\\- ]"), QRegularExpression::UseUnicodePropertiesOption);
|
||||||
|
static const QRegularExpression regex_duplicate_whitespaces(QStringLiteral(" {2,}"));
|
||||||
|
static const QRegularExpression regex_duplicate_dashes(QStringLiteral("(-)\\1+"));
|
||||||
|
|
||||||
return text.replace(QLatin1Char('/'), QLatin1Char('-'))
|
return text.replace(QLatin1Char('/'), QLatin1Char('-'))
|
||||||
.replace(QLatin1Char('\''), QLatin1Char('-'))
|
.replace(QLatin1Char('\''), QLatin1Char('-'))
|
||||||
.remove(QRegularExpression(QStringLiteral("[^\\w0-9\\- ]"), QRegularExpression::UseUnicodePropertiesOption))
|
.remove(regex_illegal_characters)
|
||||||
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
|
.replace(regex_duplicate_whitespaces, QStringLiteral(" "))
|
||||||
.simplified()
|
.simplified()
|
||||||
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
.replace(QLatin1Char(' '), QLatin1Char('-'))
|
||||||
.replace(QRegularExpression(QStringLiteral("(-)\\1+")), QStringLiteral("-"))
|
.replace(regex_duplicate_dashes, QStringLiteral("-"))
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,8 @@ QString RadioModel::SortText(QString text) {
|
|||||||
else {
|
else {
|
||||||
text = text.toLower();
|
text = text.toLower();
|
||||||
}
|
}
|
||||||
text = text.remove(QRegularExpression(QStringLiteral("[^\\w ]"), QRegularExpression::UseUnicodePropertiesOption));
|
static const QRegularExpression regex_words_and_whitespaces(QStringLiteral("[^\\w ]"), QRegularExpression::UseUnicodePropertiesOption);
|
||||||
|
text = text.remove(regex_words_and_whitespaces);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
|
|||||||
}
|
}
|
||||||
QString label = obj_stream[QLatin1String("label")].toString();
|
QString label = obj_stream[QLatin1String("label")].toString();
|
||||||
QString url = obj_stream[QLatin1String("url")].toString();
|
QString url = obj_stream[QLatin1String("url")].toString();
|
||||||
if (!url.contains(QRegularExpression(QStringLiteral("^[0-9a-zA-Z]*:\\/\\/"), QRegularExpression::CaseInsensitiveOption))) {
|
static const QRegularExpression regex_url_schema(QStringLiteral("^[0-9a-zA-Z]*:\\/\\/"), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
if (!url.contains(regex_url_schema)) {
|
||||||
url.prepend(QLatin1String("https://"));
|
url.prepend(QLatin1String("https://"));
|
||||||
}
|
}
|
||||||
RadioChannel channel;
|
RadioChannel channel;
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ const double BackendSettingsPage::kDefaultBufferHighWatermark = 0.99;
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr char kOutputAutomaticallySelect[] = "Automatically select";
|
constexpr char kOutputAutomaticallySelect[] = "Automatically select";
|
||||||
constexpr char kOutputCustom[] = "Custom";
|
constexpr char kOutputCustom[] = "Custom";
|
||||||
|
static const QRegularExpression kRegex_ALSA_HW(QStringLiteral("^hw:.*"));
|
||||||
|
static const QRegularExpression kRegex_ALSA_PlugHW(QStringLiteral("^plughw:.*"));
|
||||||
|
static const QRegularExpression kRegex_ALSA_PCM_Card(QStringLiteral("^.*:.*CARD=.*"));
|
||||||
|
static const QRegularExpression kRegex_ALSA_PCM_Dev(QStringLiteral("^.*:.*DEV=.*"));
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||||
@@ -398,15 +402,15 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
|||||||
ui_->radiobutton_alsa_hw->setEnabled(true);
|
ui_->radiobutton_alsa_hw->setEnabled(true);
|
||||||
ui_->radiobutton_alsa_plughw->setEnabled(true);
|
ui_->radiobutton_alsa_plughw->setEnabled(true);
|
||||||
ui_->radiobutton_alsa_pcm->setEnabled(true);
|
ui_->radiobutton_alsa_pcm->setEnabled(true);
|
||||||
if (device.toString().contains(QRegularExpression(QStringLiteral("^hw:.*")))) {
|
if (device.toString().contains(kRegex_ALSA_HW)) {
|
||||||
ui_->radiobutton_alsa_hw->setChecked(true);
|
ui_->radiobutton_alsa_hw->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::HW);
|
SwitchALSADevices(ALSAPluginType::HW);
|
||||||
}
|
}
|
||||||
else if (device.toString().contains(QRegularExpression(QStringLiteral("^plughw:.*")))) {
|
else if (device.toString().contains(kRegex_ALSA_PlugHW)) {
|
||||||
ui_->radiobutton_alsa_plughw->setChecked(true);
|
ui_->radiobutton_alsa_plughw->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::PlugHW);
|
SwitchALSADevices(ALSAPluginType::PlugHW);
|
||||||
}
|
}
|
||||||
else if (device.toString().contains(QRegularExpression(QStringLiteral("^.*:.*CARD=.*"))) || device.toString().contains(QRegularExpression(QStringLiteral("^.*:.*DEV=.*")))) {
|
else if (device.toString().contains(kRegex_ALSA_PCM_Card) || device.toString().contains(kRegex_ALSA_PCM_Dev)) {
|
||||||
ui_->radiobutton_alsa_pcm->setChecked(true);
|
ui_->radiobutton_alsa_pcm->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::PCM);
|
SwitchALSADevices(ALSAPluginType::PCM);
|
||||||
}
|
}
|
||||||
@@ -623,15 +627,15 @@ void BackendSettingsPage::DeviceStringChanged() {
|
|||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
if (engine()->ALSADeviceSupport(output.name)) {
|
if (engine()->ALSADeviceSupport(output.name)) {
|
||||||
if (ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^hw:.*"))) && !ui_->radiobutton_alsa_hw->isChecked()) {
|
if (ui_->lineedit_device->text().contains(kRegex_ALSA_HW) && !ui_->radiobutton_alsa_hw->isChecked()) {
|
||||||
ui_->radiobutton_alsa_hw->setChecked(true);
|
ui_->radiobutton_alsa_hw->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::HW);
|
SwitchALSADevices(ALSAPluginType::HW);
|
||||||
}
|
}
|
||||||
else if (ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^plughw:.*"))) && !ui_->radiobutton_alsa_plughw->isChecked()) {
|
else if (ui_->lineedit_device->text().contains(kRegex_ALSA_PlugHW) && !ui_->radiobutton_alsa_plughw->isChecked()) {
|
||||||
ui_->radiobutton_alsa_plughw->setChecked(true);
|
ui_->radiobutton_alsa_plughw->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::PlugHW);
|
SwitchALSADevices(ALSAPluginType::PlugHW);
|
||||||
}
|
}
|
||||||
else if ((ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^.*:.*CARD=.*"))) || ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^.*:.*DEV=.*")))) && !ui_->radiobutton_alsa_pcm->isChecked()) {
|
else if ((ui_->lineedit_device->text().contains(kRegex_ALSA_PCM_Card) || ui_->lineedit_device->text().contains(kRegex_ALSA_PCM_Dev)) && !ui_->radiobutton_alsa_pcm->isChecked()) {
|
||||||
ui_->radiobutton_alsa_pcm->setChecked(true);
|
ui_->radiobutton_alsa_pcm->setChecked(true);
|
||||||
SwitchALSADevices(ALSAPluginType::PCM);
|
SwitchALSADevices(ALSAPluginType::PCM);
|
||||||
}
|
}
|
||||||
@@ -712,11 +716,11 @@ void BackendSettingsPage::SwitchALSADevices(const ALSAPluginType alsa_plugin_typ
|
|||||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||||
QListView *view = qobject_cast<QListView*>(ui_->combobox_device->view());
|
QListView *view = qobject_cast<QListView*>(ui_->combobox_device->view());
|
||||||
if (!view) continue;
|
if (!view) continue;
|
||||||
if ((ui_->combobox_device->itemData(i).toString().contains(QRegularExpression(QStringLiteral("^hw:.*"))) && alsa_plugin_type != ALSAPluginType::HW)
|
if ((ui_->combobox_device->itemData(i).toString().contains(kRegex_ALSA_HW) && alsa_plugin_type != ALSAPluginType::HW)
|
||||||
||
|
||
|
||||||
(ui_->combobox_device->itemData(i).toString().contains(QRegularExpression(QStringLiteral("^plughw:.*"))) && alsa_plugin_type != ALSAPluginType::PlugHW)
|
(ui_->combobox_device->itemData(i).toString().contains(kRegex_ALSA_PlugHW) && alsa_plugin_type != ALSAPluginType::PlugHW)
|
||||||
||
|
||
|
||||||
((ui_->combobox_device->itemData(i).toString().contains(QRegularExpression(QStringLiteral("^.*:.*CARD=.*"))) || ui_->combobox_device->itemData(i).toString().contains(QRegularExpression(QStringLiteral("^.*:.*DEV=.*")))) && alsa_plugin_type != ALSAPluginType::PCM)
|
((ui_->combobox_device->itemData(i).toString().contains(kRegex_ALSA_PCM_Card) || ui_->combobox_device->itemData(i).toString().contains(kRegex_ALSA_PCM_Dev)) && alsa_plugin_type != ALSAPluginType::PCM)
|
||||||
) {
|
) {
|
||||||
view->setRowHidden(i, true);
|
view->setRowHidden(i, true);
|
||||||
}
|
}
|
||||||
@@ -743,11 +747,11 @@ void BackendSettingsPage::radiobutton_alsa_hw_clicked(const bool checked) {
|
|||||||
|
|
||||||
QString device_new = ui_->lineedit_device->text();
|
QString device_new = ui_->lineedit_device->text();
|
||||||
|
|
||||||
if (device_new.contains(QRegularExpression(QStringLiteral("^plughw:.*")))) {
|
if (device_new.contains(kRegex_ALSA_PlugHW)) {
|
||||||
device_new = device_new.replace(QRegularExpression(QStringLiteral("^plughw:")), QStringLiteral("hw:"));
|
device_new = device_new.replace(kRegex_ALSA_PlugHW, QStringLiteral("hw:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device_new.contains(QRegularExpression(QStringLiteral("^hw:.*")))) {
|
if (!device_new.contains(kRegex_ALSA_HW)) {
|
||||||
device_new.clear();
|
device_new.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,11 +776,11 @@ void BackendSettingsPage::radiobutton_alsa_plughw_clicked(const bool checked) {
|
|||||||
|
|
||||||
QString device_new = ui_->lineedit_device->text();
|
QString device_new = ui_->lineedit_device->text();
|
||||||
|
|
||||||
if (device_new.contains(QRegularExpression(QStringLiteral("^hw:.*")))) {
|
if (device_new.contains(kRegex_ALSA_HW)) {
|
||||||
device_new = device_new.replace(QRegularExpression(QStringLiteral("^hw:")), QStringLiteral("plughw:"));
|
device_new = device_new.replace(kRegex_ALSA_HW, QStringLiteral("plughw:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device_new.contains(QRegularExpression(QStringLiteral("^plughw:.*")))) {
|
if (!device_new.contains(kRegex_ALSA_PlugHW)) {
|
||||||
device_new.clear();
|
device_new.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,7 +805,7 @@ void BackendSettingsPage::radiobutton_alsa_pcm_clicked(const bool checked) {
|
|||||||
|
|
||||||
QString device_new = ui_->lineedit_device->text();
|
QString device_new = ui_->lineedit_device->text();
|
||||||
|
|
||||||
if (!device_new.contains(QRegularExpression(QStringLiteral("^.*:.*CARD=.*"))) && !device_new.contains(QRegularExpression(QStringLiteral("^.*:.*DEV=.*")))) {
|
if (!device_new.contains(kRegex_ALSA_PCM_Card) && !device_new.contains(kRegex_ALSA_PCM_Dev)) {
|
||||||
device_new.clear();
|
device_new.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +862,7 @@ void BackendSettingsPage::FadingOptionsChanged() {
|
|||||||
|
|
||||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||||
if (engine()->type() == EngineBase::Type::GStreamer &&
|
if (engine()->type() == EngineBase::Type::GStreamer &&
|
||||||
(!engine()->ALSADeviceSupport(output.name) || ui_->lineedit_device->text().isEmpty() || (!ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^hw:.*"))) && !ui_->lineedit_device->text().contains(QRegularExpression(QStringLiteral("^plughw:.*")))))) {
|
(!engine()->ALSADeviceSupport(output.name) || ui_->lineedit_device->text().isEmpty() || (!ui_->lineedit_device->text().contains(kRegex_ALSA_HW) && !ui_->lineedit_device->text().contains(kRegex_ALSA_PlugHW)))) {
|
||||||
ui_->groupbox_fading->setEnabled(true);
|
ui_->groupbox_fading->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *pa
|
|||||||
if (dir2.exists()) {
|
if (dir2.exists()) {
|
||||||
codes << dir2.entryList(QStringList() << QStringLiteral("*.qm"));
|
codes << dir2.entryList(QStringList() << QStringLiteral("*.qm"));
|
||||||
}
|
}
|
||||||
QRegularExpression lang_re(QStringLiteral("^strawberry_(.*).qm$"));
|
static const QRegularExpression lang_re(QStringLiteral("^strawberry_(.*).qm$"));
|
||||||
for (const QString &filename : std::as_const(codes)) {
|
for (const QString &filename : std::as_const(codes)) {
|
||||||
|
|
||||||
QRegularExpressionMatch re_match = lang_re.match(filename);
|
QRegularExpressionMatch re_match = lang_re.match(filename);
|
||||||
|
|||||||
@@ -436,7 +436,8 @@ void StreamingSearchView::SwapModels() {
|
|||||||
|
|
||||||
QStringList StreamingSearchView::TokenizeQuery(const QString &query) {
|
QStringList StreamingSearchView::TokenizeQuery(const QString &query) {
|
||||||
|
|
||||||
QStringList tokens(query.split(QRegularExpression(QStringLiteral("\\s+"))));
|
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s+"));
|
||||||
|
QStringList tokens = query.split(regex_whitespaces);
|
||||||
|
|
||||||
for (QStringList::iterator it = tokens.begin(); it != tokens.end(); ++it) {
|
for (QStringList::iterator it = tokens.begin(); it != tokens.end(); ++it) {
|
||||||
(*it).remove(QLatin1Char('('));
|
(*it).remove(QLatin1Char('('));
|
||||||
|
|||||||
@@ -94,7 +94,10 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc
|
|||||||
filename = CoverFilenameFromVariable(options, artist, album);
|
filename = CoverFilenameFromVariable(options, artist, album);
|
||||||
filename.remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption)).remove(QLatin1Char('/')).remove(QLatin1Char('\\'));
|
filename.remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption)).remove(QLatin1Char('/')).remove(QLatin1Char('\\'));
|
||||||
if (options.cover_lowercase) filename = filename.toLower();
|
if (options.cover_lowercase) filename = filename.toLower();
|
||||||
if (options.cover_replace_spaces) filename.replace(QRegularExpression(QStringLiteral("\\s")), QStringLiteral("-"));
|
if (options.cover_replace_spaces) {
|
||||||
|
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||||
|
filename.replace(regex_whitespaces, QStringLiteral("-"));
|
||||||
|
}
|
||||||
if (!extension.isEmpty()) {
|
if (!extension.isEmpty()) {
|
||||||
filename.append(QLatin1Char('.'));
|
filename.append(QLatin1Char('.'));
|
||||||
filename.append(extension);
|
filename.append(extension);
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
|
|||||||
if (setting.contains(QLatin1String("Exec"))) {
|
if (setting.contains(QLatin1String("Exec"))) {
|
||||||
QString cmd = setting.value(QStringLiteral("Exec")).toString();
|
QString cmd = setting.value(QStringLiteral("Exec")).toString();
|
||||||
if (cmd.isEmpty()) break;
|
if (cmd.isEmpty()) break;
|
||||||
cmd = cmd.remove(QRegularExpression(QStringLiteral("[%][a-zA-Z]*( |$)"), QRegularExpression::CaseInsensitiveOption));
|
static const QRegularExpression regex(QStringLiteral("[%][a-zA-Z]*( |$)"), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
cmd = cmd.remove(regex);
|
||||||
# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
command_params = cmd.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
command_params = cmd.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||||
# else
|
# else
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ QString DecodeHtmlEntities(const QString &text) {
|
|||||||
|
|
||||||
QString ReplaceMessage(const QString &message, const Song &song, const QString &newline, const bool html_escaped) {
|
QString ReplaceMessage(const QString &message, const Song &song, const QString &newline, const bool html_escaped) {
|
||||||
|
|
||||||
QRegularExpression variable_replacer(QStringLiteral("[%][a-z]+[%]"));
|
static const QRegularExpression variable_replacer(QStringLiteral("[%][a-z]+[%]"));
|
||||||
QString copy(message);
|
QString copy(message);
|
||||||
|
|
||||||
// Replace the first line
|
// Replace the first line
|
||||||
@@ -125,7 +125,8 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
|
|||||||
pos += match.capturedLength();
|
pos += match.capturedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 index_of = copy.indexOf(QRegularExpression(QStringLiteral(" - (>|$)")));
|
static const QRegularExpression regexp(QStringLiteral(" - (>|$)"));
|
||||||
|
qint64 index_of = copy.indexOf(regexp);
|
||||||
if (index_of >= 0) copy = copy.remove(index_of, 3);
|
if (index_of >= 0) copy = copy.remove(index_of, 3);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ QString PrettyFutureDate(const QDate date) {
|
|||||||
|
|
||||||
QDateTime ParseRFC822DateTime(const QString &text) {
|
QDateTime ParseRFC822DateTime(const QString &text) {
|
||||||
|
|
||||||
QRegularExpression regexp(QStringLiteral("(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"));
|
static const QRegularExpression regexp(QStringLiteral("(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"));
|
||||||
QRegularExpressionMatch re_match = regexp.match(text);
|
QRegularExpressionMatch re_match = regexp.match(text);
|
||||||
if (!re_match.hasMatch()) {
|
if (!re_match.hasMatch()) {
|
||||||
return QDateTime();
|
return QDateTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user