Replace QRegExp with QRegularExpression (#2945)
This commit is contained in:
+5
-5
@@ -133,11 +133,11 @@ void Args::applyCustomChannelLayout(const QString &argValue)
|
|||||||
QString platform = "t";
|
QString platform = "t";
|
||||||
QString channelName = channelArg;
|
QString channelName = channelArg;
|
||||||
|
|
||||||
const QRegExp regExp("(.):(.*)");
|
const QRegularExpression regExp("(.):(.*)");
|
||||||
if (regExp.indexIn(channelArg) != -1)
|
if (auto match = regExp.match(channelArg); match.hasMatch())
|
||||||
{
|
{
|
||||||
platform = regExp.cap(1);
|
platform = match.captured(1);
|
||||||
channelName = regExp.cap(2);
|
channelName = match.captured(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twitch (default)
|
// Twitch (default)
|
||||||
@@ -147,7 +147,7 @@ void Args::applyCustomChannelLayout(const QString &argValue)
|
|||||||
|
|
||||||
// Set first tab as selected
|
// Set first tab as selected
|
||||||
tab.selected_ = window.tabs_.empty();
|
tab.selected_ = window.tabs_.empty();
|
||||||
tab.rootNode_ = SplitNodeDescriptor{"twitch", channelName};
|
tab.rootNode_ = SplitNodeDescriptor{{"twitch", channelName}};
|
||||||
|
|
||||||
window.tabs_.emplace_back(std::move(tab));
|
window.tabs_.emplace_back(std::move(tab));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,12 +105,15 @@ QString getJSONValue(QJsonValue responseJson, QString jsonPattern)
|
|||||||
|
|
||||||
QString getLinkFromResponse(NetworkResult response, QString pattern)
|
QString getLinkFromResponse(NetworkResult response, QString pattern)
|
||||||
{
|
{
|
||||||
QRegExp regExp("\\{(.+)\\}");
|
QRegularExpression regExp("{(.+)}",
|
||||||
regExp.setMinimal(true);
|
QRegularExpression::InvertedGreedinessOption);
|
||||||
while (regExp.indexIn(pattern) != -1)
|
auto match = regExp.match(pattern);
|
||||||
|
|
||||||
|
while (match.hasMatch())
|
||||||
{
|
{
|
||||||
pattern.replace(regExp.cap(0),
|
pattern.replace(match.captured(0),
|
||||||
getJSONValue(response.parseJson(), regExp.cap(1)));
|
getJSONValue(response.parseJson(), match.captured(1)));
|
||||||
|
match = regExp.match(pattern);
|
||||||
}
|
}
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user