mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Replace QRegExp with QRegularExpression
Revise `static` keyword usage, static is added to frequently used instances.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QListWidgetItem>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "guiiconprovider.h"
|
||||
|
||||
@@ -95,10 +95,10 @@ void LogListWidget::appendLine(const QString &line, const Log::MsgType &type)
|
||||
|
||||
void LogListWidget::copySelection()
|
||||
{
|
||||
static QRegExp htmlTag("<[^>]+>");
|
||||
static const QRegularExpression htmlTag("<[^>]+>");
|
||||
QStringList strings;
|
||||
foreach (QListWidgetItem* it, selectedItems())
|
||||
strings << static_cast<QLabel*>(itemWidget(it))->text().replace(htmlTag, "");
|
||||
strings << static_cast<QLabel*>(itemWidget(it))->text().remove(htmlTag);
|
||||
|
||||
QApplication::clipboard()->setText(strings.join("\n"));
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QScrollBar>
|
||||
#include <QShortcut>
|
||||
#include <QSplitter>
|
||||
@@ -1599,8 +1600,8 @@ void MainWindow::downloadFromURLList(const QStringList &urlList)
|
||||
{
|
||||
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
||||
foreach (QString url, urlList) {
|
||||
if (((url.size() == 40) && !url.contains(QRegExp("[^0-9A-Fa-f]")))
|
||||
|| ((url.size() == 32) && !url.contains(QRegExp("[^2-7A-Za-z]"))))
|
||||
if (((url.size() == 40) && !url.contains(QRegularExpression("[^0-9A-Fa-f]")))
|
||||
|| ((url.size() == 32) && !url.contains(QRegularExpression("[^2-7A-Za-z]"))))
|
||||
url = "magnet:?xt=urn:btih:" + url;
|
||||
|
||||
if (useTorrentAdditionDialog)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
@@ -136,9 +136,9 @@ void ProgramUpdater::updateProgram()
|
||||
|
||||
bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
|
||||
{
|
||||
QRegExp regVer("([0-9.]+)");
|
||||
if (regVer.indexIn(QBT_VERSION) >= 0) {
|
||||
QString localVersion = regVer.cap(1);
|
||||
const QRegularExpressionMatch regVerMatch = QRegularExpression("([0-9.]+)").match(QBT_VERSION);
|
||||
if (regVerMatch.hasMatch()) {
|
||||
QString localVersion = regVerMatch.captured(1);
|
||||
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
|
||||
QStringList remoteParts = remoteVersion.split('.');
|
||||
QStringList localParts = localVersion.split('.');
|
||||
@@ -152,8 +152,8 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
|
||||
if (remoteParts.size() > localParts.size())
|
||||
return true;
|
||||
// versions are equal, check if the local version is a development release, in which case it is older (2.9.2beta < 2.9.2)
|
||||
QRegExp regDevel("(alpha|beta|rc)");
|
||||
if (regDevel.indexIn(QBT_VERSION) >= 0)
|
||||
const QRegularExpressionMatch regDevelMatch = QRegularExpression("(alpha|beta|rc)").match(QBT_VERSION);
|
||||
if (regDevelMatch.hasMatch())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QDragMoveEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardItemModel>
|
||||
#include <QString>
|
||||
|
||||
@@ -461,10 +462,10 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL
|
||||
}
|
||||
else {
|
||||
QString description = article->description();
|
||||
QRegExp rx;
|
||||
QRegularExpression rx;
|
||||
// If description is plain text, replace BBCode tags with HTML and wrap everything in <pre></pre> so it looks nice
|
||||
rx.setMinimal(true);
|
||||
rx.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
rx.setPatternOptions(QRegularExpression::InvertedGreedinessOption
|
||||
| QRegularExpression::CaseInsensitiveOption);
|
||||
|
||||
rx.setPattern("\\[img\\](.+)\\[/img\\]");
|
||||
description = description.replace(rx, "<img src=\"\\1\">");
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QSignalMapper>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
@@ -323,7 +323,7 @@ void SearchWidget::on_searchButton_clicked()
|
||||
m_allTabs.append(newTab);
|
||||
|
||||
QString tabName = pattern;
|
||||
tabName.replace(QRegExp("&{1}"), "&&");
|
||||
tabName.replace(QRegularExpression("&{1}"), "&&");
|
||||
m_ui->tabWidget->addTab(newTab, tabName);
|
||||
m_ui->tabWidget->setCurrentWidget(newTab);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QShortcut>
|
||||
#include <QStylePainter>
|
||||
#include <QTableView>
|
||||
@@ -830,7 +831,7 @@ void TransferListWidget::renameSelectedTorrent()
|
||||
bool ok;
|
||||
QString name = AutoExpandableDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, torrent->name(), &ok);
|
||||
if (ok && !name.isEmpty()) {
|
||||
name.replace(QRegExp("\r?\n|\r"), " ");
|
||||
name.replace(QRegularExpression("\r?\n|\r"), " ");
|
||||
// Rename the torrent
|
||||
m_listModel->setData(mi, name, Qt::DisplayRole);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user