Commit 4537f3a5 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

[PATCH 3] Port some QRegExp usage to QRegularExpression

Use QRegularExpression::anchoredPattern() to get a behaviour similar to
QRegExp::exactMatch().
parent 2c1bdd16
......@@ -318,10 +318,10 @@ namespace Konversation
{
getTextView()->append(m_chat->partnerNick(), line);
QRegExp regexp(QStringLiteral("(^|[^\\d\\w])") +
QRegExp::escape(m_chat->ownNick()) +
QStringLiteral("([^\\d\\w]|$)"));
regexp.setCaseSensitivity(Qt::CaseInsensitive);
const QRegularExpression regexp(QLatin1String("(^|[^\\d\\w])")
+ QRegularExpression::escape(m_chat->ownNick())
+ QLatin1String("([^\\d\\w]|$)"),
QRegularExpression::CaseInsensitiveOption);
if(line.contains(regexp))
{
......
......@@ -7,6 +7,7 @@
#include "irccharsets.h"
#include <QLocale>
#include <QRegularExpression>
#include <QTextCodec>
#include <KCharsets>
......@@ -61,7 +62,7 @@ namespace Konversation
{
// simplify ambiguousName
QString simplifiedAmbiguousName( ambiguousName.toLower() );
simplifiedAmbiguousName.remove( QRegExp( QStringLiteral("[^a-z0-9]") ));
simplifiedAmbiguousName.remove( QRegularExpression( QStringLiteral("[^a-z0-9]") ));
// search m_simplifiedShortNames
if(m_simplifiedShortNames.contains(simplifiedAmbiguousName))
......@@ -122,7 +123,7 @@ namespace Konversation
m_simplifiedShortNames[QStringLiteral("latin1")] = QStringLiteral("ISO 8859-1");
// setup m_shortNames, m_descriptiveNames, m_simplifiedShortNames
QRegExp reSimplify( QStringLiteral("[^a-zA-Z0-9]") );
const QRegularExpression reSimplify( QStringLiteral("[^a-zA-Z0-9]") );
m_descriptiveNames = KCharsets::charsets()->descriptiveEncodingNames();
QStringList::Iterator it = m_descriptiveNames.begin();
while ( it != m_descriptiveNames.end() )
......
......@@ -34,7 +34,7 @@
#include <QStringList>
#include <QFile>
#include <QMetaMethod>
#include <QRegExp>
#include <QRegularExpression>
#include <QTextCodec>
#include <QByteArray>
#include <QTextStream>
......@@ -1628,13 +1628,13 @@ namespace Konversation
emit reconnectServer(QString());
else
{
QStringList parameterList = input.parameter.split(QLatin1Char(' '));
const QStringList parameterList = input.parameter.split(QLatin1Char(' '));
if (parameterList.count() == 3)
emit connectTo(Konversation::CreateNewConnection, parameterList[0], parameterList[1], parameterList[2]);
else if (parameterList.count() == 2)
{
if (parameterList[0].contains(QRegExp(QStringLiteral(":[0-9]+$"))))
if (parameterList[0].contains(QRegularExpression(QStringLiteral(":[0-9]+$"))))
emit connectTo(Konversation::CreateNewConnection, parameterList[0], QString(), parameterList[1]);
else
emit connectTo(Konversation::CreateNewConnection, parameterList[0], parameterList[1]);
......@@ -2072,9 +2072,10 @@ namespace Konversation
bool OutputFilter::isParameter(const QString& parameter, const QString& string) const
{
QRegExp rx(QStringLiteral("^[\\-]{1,2}%1$").arg(parameter), Qt::CaseInsensitive);
const QString pattern = QRegularExpression::anchoredPattern(QStringLiteral("^[\\-]{1,2}%1$").arg(parameter));
const QRegularExpression rx(pattern, QRegularExpression::CaseInsensitiveOption);
return rx.exactMatch(string);
return rx.match(string).hasMatch();
}
}
......
......@@ -4114,7 +4114,8 @@ void Server::setAway(bool away, const QHash<QString, QString> &messageTags)
if (identity && identity->getRunAwayCommands())
{
QString message = identity->getAwayCommand();
sendToAllChannels(message.replace(QRegExp(QStringLiteral("%s"), Qt::CaseInsensitive), m_awayReason));
const QRegularExpression re(QStringLiteral("%s"), QRegularExpression::CaseInsensitiveOption);
sendToAllChannels(message.replace(re, m_awayReason));
}
if (identity && identity->getInsertRememberLineOnAway())
......@@ -4139,7 +4140,8 @@ void Server::setAway(bool away, const QHash<QString, QString> &messageTags)
if (identity && identity->getRunAwayCommands())
{
QString message = identity->getReturnCommand();
sendToAllChannels(message.replace(QRegExp(QStringLiteral("%t"), Qt::CaseInsensitive), awayTime()));
const QRegularExpression re(QStringLiteral("%t"), QRegularExpression::CaseInsensitiveOption);
sendToAllChannels(message.replace(re, awayTime()));
}
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment