mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-15 08:39:08 -05:00
Replaced deprecated QRegExp by QRegularExpression
This commit is contained in:
parent
f0286740f4
commit
13b294838b
8 changed files with 26 additions and 18 deletions
|
|
@ -20,6 +20,8 @@
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "guiexprelement.h"
|
#include "guiexprelement.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
|
||||||
|
|
@ -400,10 +402,10 @@ void ExprParamElement::adjustForSearchType(ExprSearchType type)
|
||||||
{
|
{
|
||||||
// record which search type is active
|
// record which search type is active
|
||||||
searchType = type;
|
searchType = type;
|
||||||
QRegExp regExp("0|[1-9][0-9]*");
|
QRegularExpression regExp("0|[1-9][0-9]*");
|
||||||
numValidator = new QRegExpValidator(regExp, this);
|
numValidator = new QRegularExpressionValidator(regExp, this);
|
||||||
QRegExp hexRegExp("[A-Fa-f0-9]*");
|
QRegularExpression hexRegExp("[A-Fa-f0-9]*");
|
||||||
hexValidator = new QRegExpValidator(hexRegExp, this);
|
hexValidator = new QRegularExpressionValidator(hexRegExp, this);
|
||||||
|
|
||||||
QHBoxLayout* hbox = static_cast<QHBoxLayout*>(layout());
|
QHBoxLayout* hbox = static_cast<QHBoxLayout*>(layout());
|
||||||
clearLayout(hbox);
|
clearLayout(hbox);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
class QRegularExpressionValidator;
|
||||||
|
|
||||||
enum ExprSearchType
|
enum ExprSearchType
|
||||||
{
|
{
|
||||||
NameSearch,
|
NameSearch,
|
||||||
|
|
@ -191,8 +193,8 @@ public:
|
||||||
virtual QString toString();
|
virtual QString toString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRegExpValidator * numValidator;
|
QRegularExpressionValidator * numValidator;
|
||||||
QRegExpValidator * hexValidator;
|
QRegularExpressionValidator * hexValidator;
|
||||||
QFrame * rangeParamsFrame;
|
QFrame * rangeParamsFrame;
|
||||||
bool inRangedConfig;
|
bool inRangedConfig;
|
||||||
uint64_t getIntValueFromField(QString fieldName, bool isToField=false,bool *ok = NULL);
|
uint64_t getIntValueFromField(QString fieldName, bool isToField=false,bool *ok = NULL);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "ChatStyle.h"
|
#include "ChatStyle.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
|
@ -376,7 +377,7 @@ QString ChatStyle::formatMessage(enumFormatMessage type
|
||||||
QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("<a name=\"date\">")).append(QString("</a>"));
|
QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("<a name=\"date\">")).append(QString("</a>"));
|
||||||
QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("<a name=\"time\">")).append(QString("</a>"));
|
QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("<a name=\"time\">")).append(QString("</a>"));
|
||||||
|
|
||||||
int bi = name.lastIndexOf(QRegExp(" \\(.*\\)")); //trim location from the end
|
int bi = name.lastIndexOf(QRegularExpression(" \\(.*\\)")); //trim location from the end
|
||||||
QString strShortName = RsHtml::plainText(name.left(bi)).prepend(QString("<a name=\"name\">")).append(QString("</a>"));
|
QString strShortName = RsHtml::plainText(name.left(bi)).prepend(QString("<a name=\"name\">")).append(QString("</a>"));
|
||||||
|
|
||||||
//handle /me
|
//handle /me
|
||||||
|
|
@ -384,9 +385,9 @@ QString ChatStyle::formatMessage(enumFormatMessage type
|
||||||
//meName class for modifying the style of the name in the palce of /me
|
//meName class for modifying the style of the name in the palce of /me
|
||||||
if(me){
|
if(me){
|
||||||
messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strShortName.prepend(QString("<span class=\"meName\">")).append(QString("</span>"))); //replace only the first /me
|
messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strShortName.prepend(QString("<span class=\"meName\">")).append(QString("</span>"))); //replace only the first /me
|
||||||
style = style.remove(QRegExp("%nome%.*%/nome%")).remove("%me%").remove("%/me%");
|
style = style.remove(QRegularExpression("%nome%.*%/nome%")).remove("%me%").remove("%/me%");
|
||||||
} else {
|
} else {
|
||||||
style = style.remove(QRegExp("%me%.*%/me%")).remove("%nome%").remove("%/nome%");
|
style = style.remove(QRegularExpression("%me%.*%/me%")).remove("%nome%").remove("%/nome%");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString formatMsg = style.replace("%name%", strName)
|
QString formatMsg = style.replace("%name%", strName)
|
||||||
|
|
|
||||||
|
|
@ -640,7 +640,7 @@ void MessageWidget::fill(const std::string &msgId)
|
||||||
|
|
||||||
ui.trans_ToText->setText(to_text);
|
ui.trans_ToText->setText(to_text);
|
||||||
|
|
||||||
int recipientsCount = ui.trans_ToText->toPlainText().split(QRegExp("(\\s|\\n|\\r)+"), QtSkipEmptyParts).count();
|
int recipientsCount = ui.trans_ToText->toPlainText().split(QRegularExpression("(\\s|\\n|\\r)+"), QtSkipEmptyParts).count();
|
||||||
ui.expandButton->setText( QString::number(recipientsCount)+ " " + tr("more"));
|
ui.expandButton->setText( QString::number(recipientsCount)+ " " + tr("more"));
|
||||||
|
|
||||||
if (recipientsCount >=20) {
|
if (recipientsCount >=20) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
@ -311,8 +311,8 @@ void RsApplication::customizeDateFormat()
|
||||||
QLocale locale = QLocale(); // set to default locale
|
QLocale locale = QLocale(); // set to default locale
|
||||||
/* get long date format without weekday */
|
/* get long date format without weekday */
|
||||||
options.dateformat = locale.dateFormat(QLocale::LongFormat);
|
options.dateformat = locale.dateFormat(QLocale::LongFormat);
|
||||||
options.dateformat.replace(QRegExp("^dddd,*[^ ]* *('[^']+' )*"), "");
|
options.dateformat.replace(QRegularExpression("^dddd,*[^ ]* *('[^']+' )*"), "");
|
||||||
options.dateformat.replace(QRegExp(",* *dddd"), "");
|
options.dateformat.replace(QRegularExpression(",* *dddd"), "");
|
||||||
options.dateformat = options.dateformat.trimmed();
|
options.dateformat = options.dateformat.trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "HandleRichText.h"
|
#include "HandleRichText.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
|
|
@ -1171,7 +1172,7 @@ void RsHtml::optimizeHtml(QString &text, unsigned int flag /*= 0*/
|
||||||
{
|
{
|
||||||
|
|
||||||
// remove doctype
|
// remove doctype
|
||||||
text.remove(QRegExp("<!DOCTYPE[^>]*>"));
|
text.remove(QRegularExpression("<!DOCTYPE[^>]*>"));
|
||||||
//remove all prepend char that make doc.setContent() fail
|
//remove all prepend char that make doc.setContent() fail
|
||||||
text.remove(0,text.indexOf("<"));
|
text.remove(0,text.indexOf("<"));
|
||||||
// Save Space and Tab because doc loose it.
|
// Save Space and Tab because doc loose it.
|
||||||
|
|
@ -1253,7 +1254,7 @@ QString RsHtml::makeQuotedText(RSTextBrowser *browser)
|
||||||
{
|
{
|
||||||
text = browser->toPlainText();
|
text = browser->toPlainText();
|
||||||
}
|
}
|
||||||
QStringList sl = text.split(QRegExp("[\r\n]"),QtSkipEmptyParts);
|
QStringList sl = text.split(QRegularExpression("[\r\n]"),QtSkipEmptyParts);
|
||||||
text = sl.join("\n> ");
|
text = sl.join("\n> ");
|
||||||
text.replace("\n> >","\n>>"); // Don't add space for already quotted lines.
|
text.replace("\n> >","\n>>"); // Don't add space for already quotted lines.
|
||||||
text.replace(QChar(-4)," ");//Char used when image on text.
|
text.replace(QChar(-4)," ");//Char used when image on text.
|
||||||
|
|
|
||||||
|
|
@ -547,9 +547,9 @@ void RichTextEdit::slotClipboardDataChanged() {
|
||||||
QString RichTextEdit::toHtml() const {
|
QString RichTextEdit::toHtml() const {
|
||||||
QString s = f_textedit->toHtml();
|
QString s = f_textedit->toHtml();
|
||||||
// convert emails to links
|
// convert emails to links
|
||||||
s = s.replace(QRegExp("(<[^a][^>]+>(?:<span[^>]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1<a href=\"mailto:\\2\">\\2</a>");
|
s = s.replace(QRegularExpression("(<[^a][^>]+>(?:<span[^>]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1<a href=\"mailto:\\2\">\\2</a>");
|
||||||
// convert links
|
// convert links
|
||||||
s = s.replace(QRegExp("(<[^a][^>]+>(?:<span[^>]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1<a href=\"\\2\">\\2</a>");
|
s = s.replace(QRegularExpression("(<[^a][^>]+>(?:<span[^>]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1<a href=\"\\2\">\\2</a>");
|
||||||
// see also: Utils::linkify()
|
// see also: Utils::linkify()
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "RsSyntaxHighlighter.h"
|
#include "RsSyntaxHighlighter.h"
|
||||||
|
|
||||||
RsSyntaxHighlighter::RsSyntaxHighlighter(QTextEdit *parent)
|
RsSyntaxHighlighter::RsSyntaxHighlighter(QTextEdit *parent)
|
||||||
|
|
@ -65,7 +67,7 @@ void RsSyntaxHighlighter::highlightBlock(const QString &text)
|
||||||
{
|
{
|
||||||
if (text == "") return;
|
if (text == "") return;
|
||||||
|
|
||||||
QRegExp endl("[\\r\\n\\x2028]"); //Usually 0x2028 character is used for newline, no idea why
|
QRegularExpression endl("[\\r\\n\\x2028]"); //Usually 0x2028 character is used for newline, no idea why
|
||||||
int index = 0;
|
int index = 0;
|
||||||
QStringList lines = text.split(endl);
|
QStringList lines = text.split(endl);
|
||||||
foreach (const QString &cLine, lines) {
|
foreach (const QString &cLine, lines) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue