diff --git a/src/application.cpp b/src/application.cpp --- a/src/application.cpp +++ b/src/application.cpp @@ -32,7 +32,7 @@ #include "awaymanager.h" #include -#include +#include #include #include #include @@ -385,7 +385,8 @@ } // Identity list - QStringList identityList=KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("Identity [0-9]+"))); + const QStringList identityList=KSharedConfig::openConfig()->groupList().filter( + QRegularExpression(QStringLiteral("Identity [0-9]+"))); if (!identityList.isEmpty()) { Preferences::clearIdentityList(); @@ -458,7 +459,8 @@ KConfigGroup cgServerList(KSharedConfig::openConfig()->group("Server List")); // Read the new server settings - QStringList groups = KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("ServerGroup [0-9]+"))); + QStringList groups = KSharedConfig::openConfig()->groupList().filter( + QRegularExpression(QStringLiteral("ServerGroup [0-9]+"))); QMap notifyList; QList sgKeys; @@ -684,31 +686,33 @@ //Legacy channel encodings read in Jun. 29, 2009 KConfigGroup cgChannelEncodings(KSharedConfig::openConfig()->group("Channel Encodings")); QMap channelEncodingEntries=cgChannelEncodings.entryMap(); - QRegExp re(QStringLiteral("^(.+) ([^\\s]+)$")); + const QRegularExpression re(QStringLiteral("^(.+) ([^\\s]+)$")); QList channelEncodingEntryKeys=channelEncodingEntries.keys(); for(QList::const_iterator itStr=channelEncodingEntryKeys.constBegin(); itStr != channelEncodingEntryKeys.constEnd(); ++itStr) { - if(re.indexIn(*itStr) > -1) + const QRegularExpressionMatch match = re.match(*itStr); + if(match.hasMatch()) { - Preferences::setChannelEncoding(re.cap(1),re.cap(2),channelEncodingEntries[*itStr]); + Preferences::setChannelEncoding(match.captured(1), match.captured(2), channelEncodingEntries[*itStr]); } } //End legacy channel encodings read in Jun 29, 2009 KConfigGroup cgEncodings(KSharedConfig::openConfig()->group("Encodings")); QMap encodingEntries=cgEncodings.entryMap(); QList encodingEntryKeys=encodingEntries.keys(); - QRegExp reg(QStringLiteral("^([^\\s]+) ([^\\s]+)\\s?([^\\s]*)$")); + const QRegularExpression reg(QStringLiteral("^([^\\s]+) ([^\\s]+)\\s?([^\\s]*)$")); for(QList::const_iterator itStr=encodingEntryKeys.constBegin(); itStr != encodingEntryKeys.constEnd(); ++itStr) { - if(reg.indexIn(*itStr) > -1) + const QRegularExpressionMatch match = reg.match(*itStr); + if(match.hasMatch()) { - if(reg.cap(1) == QLatin1String("ServerGroup") && !reg.cap(3).isEmpty()) - Preferences::setChannelEncoding(sgKeys.at(reg.cap(2).toInt()), reg.cap(3), encodingEntries[*itStr]); + if(match.captured(1) == QLatin1String("ServerGroup") && !match.captured(3).isEmpty()) + Preferences::setChannelEncoding(sgKeys.at(match.captured(2).toInt()), match.captured(3), encodingEntries[*itStr]); else - Preferences::setChannelEncoding(reg.cap(1), reg.cap(2), encodingEntries[*itStr]); + Preferences::setChannelEncoding(match.captured(1), match.captured(2), encodingEntries[*itStr]); } } @@ -719,17 +723,18 @@ for (QList::const_iterator itStr=spellCheckingLanguageEntryKeys.constBegin(); itStr != spellCheckingLanguageEntryKeys.constEnd(); ++itStr) { - if (reg.indexIn(*itStr) > -1) + const QRegularExpressionMatch match = reg.match(*itStr); + if (match.hasMatch()) { - if (reg.cap(1) == QLatin1String("ServerGroup") && !reg.cap(3).isEmpty()) + if (match.captured(1) == QLatin1String("ServerGroup") && !match.captured(3).isEmpty()) { - ServerGroupSettingsPtr serverGroup = Preferences::serverGroupById(sgKeys.at(reg.cap(2).toInt())); + ServerGroupSettingsPtr serverGroup = Preferences::serverGroupById(sgKeys.at(match.captured(2).toInt())); if (serverGroup) - Preferences::setSpellCheckingLanguage(serverGroup, reg.cap(3), spellCheckingLanguageEntries[*itStr]); + Preferences::setSpellCheckingLanguage(serverGroup, match.captured(3), spellCheckingLanguageEntries[*itStr]); } else - Preferences::setSpellCheckingLanguage(reg.cap(1), reg.cap(2), spellCheckingLanguageEntries[*itStr]); + Preferences::setSpellCheckingLanguage(match.captured(1), match.captured(2), spellCheckingLanguageEntries[*itStr]); } } @@ -748,7 +753,8 @@ // config->setGroup("Sort Nicknames"); // Clean up identity list - QStringList identities=KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("Identity [0-9]+"))); + const QStringList identities=KSharedConfig::openConfig()->groupList().filter( + QRegularExpression(QStringLiteral("Identity [0-9]+"))); if (identities.count()) { // remove old identity list from Preferences::file to keep numbering under control @@ -792,7 +798,8 @@ } // endfor // Remove the old servergroups from the config - QStringList groups = KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("ServerGroup [0-9]+"))); + QStringList groups = KSharedConfig::openConfig()->groupList().filter( + QRegularExpression(QStringLiteral("ServerGroup [0-9]+"))); if (groups.count()) { QStringList::iterator it; @@ -803,7 +810,7 @@ } // Remove the old servers from the config - groups = KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("Server [0-9]+"))); + groups = KSharedConfig::openConfig()->groupList().filter(QRegularExpression(QStringLiteral("Server [0-9]+"))); if (groups.count()) { QStringList::iterator it; @@ -814,7 +821,7 @@ } // Remove the old channels from the config - groups = KSharedConfig::openConfig()->groupList().filter(QRegExp(QStringLiteral("Channel [0-9]+"))); + groups = KSharedConfig::openConfig()->groupList().filter(QRegularExpression(QStringLiteral("Channel [0-9]+"))); if (groups.count()) { QStringList::iterator it; @@ -1141,20 +1148,19 @@ if (regex== QLatin1Char('1')) { // create regex from pattern - QRegExp needleReg(pattern); - // set pattern case insensitive - needleReg.setCaseSensitivity(Qt::CaseSensitive); + const QRegularExpression needleReg(pattern); int index = 0; int newIndex = index; do { + QRegularExpressionMatch rmatch; // find matches - index = line.indexOf(needleReg, index); + index = line.indexOf(needleReg, index, &rmatch); if (index != -1) { // remember captured patterns - QStringList captures = needleReg.capturedTexts(); + const QStringList captures = rmatch.capturedTexts(); QString replaceWith = replacement; replaceWith.replace(QStringLiteral("%%"),QStringLiteral("%\x01")); // escape double % @@ -1168,7 +1174,7 @@ //If somebody has a regex that say has a replacement of url.com/%1/%2 and the //regex can either match one or two patterns, if the 2nd pattern match is left, //the url is invalid (url.com/match/%2). This is expected regex behavior I'd assume. - replaceWith.remove(QRegExp(QStringLiteral("%[0-9]"))); + replaceWith.remove(QRegularExpression(QStringLiteral("%[0-9]"))); replaceWith.replace(QStringLiteral("%\x01"),QStringLiteral("%")); // return escaped % to normal // allow for var expansion in autoreplace @@ -1197,9 +1203,7 @@ } else { - QRegExp needleReg(pattern); - needleReg.setPatternSyntax(QRegExp::FixedString); - int index=line.indexOf(needleReg); + int index = line.indexOf(pattern); while (index>=0) { int length,nextLength,patLen,repLen; @@ -1238,7 +1242,7 @@ } } - index=line.indexOf(needleReg,nextLength); + index = line.indexOf(pattern, nextLength); } } }