mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-27 13:06:51 +00:00
Replace usage of QRegularExpression::anchoredPattern with ^
and $
Using `^` and `$` is shorter than `QRegularExpression::anchoredPattern`, and even allows us in one case to get rid of a trailing `.*`.
This commit is contained in:
parent
94259317bb
commit
c90d22f3b2
5 changed files with 6 additions and 7 deletions
|
@ -205,7 +205,7 @@ void Launcher::GraphicsPage::saveSettings()
|
||||||
int cHeight = 0;
|
int cHeight = 0;
|
||||||
if (standardRadioButton->isChecked())
|
if (standardRadioButton->isChecked())
|
||||||
{
|
{
|
||||||
QRegularExpression resolutionRe(QRegularExpression::anchoredPattern(QString("(\\d+) x (\\d+).*")));
|
QRegularExpression resolutionRe("^(\\d+) x (\\d+)");
|
||||||
QRegularExpressionMatch match = resolutionRe.match(resolutionComboBox->currentText().simplified());
|
QRegularExpressionMatch match = resolutionRe.match(resolutionComboBox->currentText().simplified());
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,8 +20,7 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString&
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
|
|
||||||
// Line edit
|
// Line edit
|
||||||
QValidator* validator
|
QValidator* validator = new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9_]*$"), this);
|
||||||
= new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
|
||||||
mLineEdit = new LineEdit(this);
|
mLineEdit = new LineEdit(this);
|
||||||
mLineEdit->setValidator(validator);
|
mLineEdit->setValidator(validator);
|
||||||
mLineEdit->setCompleter(nullptr);
|
mLineEdit->setCompleter(nullptr);
|
||||||
|
|
|
@ -30,7 +30,7 @@ bool Wizard::IniSettings::readFile(QTextStream& stream)
|
||||||
// Look for a square bracket, "'\\["
|
// Look for a square bracket, "'\\["
|
||||||
// that has one or more "not nothing" in it, "([^]]+)"
|
// that has one or more "not nothing" in it, "([^]]+)"
|
||||||
// and is closed with a square bracket, "\\]"
|
// and is closed with a square bracket, "\\]"
|
||||||
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
|
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
|
||||||
|
|
||||||
// Find any character(s) that is/are not equal sign(s), "[^=]+"
|
// Find any character(s) that is/are not equal sign(s), "[^=]+"
|
||||||
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
|
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
|
||||||
|
@ -75,7 +75,7 @@ bool Wizard::IniSettings::writeFile(const QString& path, QTextStream& stream)
|
||||||
// Look for a square bracket, "'\\["
|
// Look for a square bracket, "'\\["
|
||||||
// that has one or more "not nothing" in it, "([^]]+)"
|
// that has one or more "not nothing" in it, "([^]]+)"
|
||||||
// and is closed with a square bracket, "\\]"
|
// and is closed with a square bracket, "\\]"
|
||||||
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
|
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
|
||||||
|
|
||||||
// Find any character(s) that is/are not equal sign(s), "[^=]+"
|
// Find any character(s) that is/are not equal sign(s), "[^=]+"
|
||||||
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
|
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
|
||||||
|
|
|
@ -47,7 +47,7 @@ QStringList Config::LauncherSettings::subKeys(const QString& key)
|
||||||
bool Config::LauncherSettings::writeFile(QTextStream& stream)
|
bool Config::LauncherSettings::writeFile(QTextStream& stream)
|
||||||
{
|
{
|
||||||
QString sectionPrefix;
|
QString sectionPrefix;
|
||||||
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("([^/]+)/(.+)$"));
|
QRegularExpression sectionRe("^([^/]+)/(.+)$");
|
||||||
QMultiMap<QString, QString> settings = SettingsBase::getSettings();
|
QMultiMap<QString, QString> settings = SettingsBase::getSettings();
|
||||||
|
|
||||||
QMapIterator<QString, QString> i(settings);
|
QMapIterator<QString, QString> i(settings);
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Config
|
||||||
|
|
||||||
QString sectionPrefix;
|
QString sectionPrefix;
|
||||||
|
|
||||||
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
|
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
|
||||||
QRegularExpression keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
QRegularExpression keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
|
||||||
while (!stream.atEnd())
|
while (!stream.atEnd())
|
||||||
|
|
Loading…
Reference in a new issue