Skip to content

Commit

Permalink
Merge pull request #1333 from hjtappe/regexp-qt-6x
Browse files Browse the repository at this point in the history
Re-Enable CAPS check in fixtureeditor and update other RexExp patterns
  • Loading branch information
mcallegari authored May 18, 2022
2 parents 8bce78a + d3926da commit 9b527ab
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/src/qlcphysical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ int QLCPhysical::powerConsumption() const
/* If power consumption value is missing, return bulb watts
* plus a guesstimate 100W, since there's usually other
* electronics consuming power as well. */
int bulbWatts = bulbType().remove(QRegularExpression("[A-Z]")).toInt();
int bulbWatts = bulbType().remove(QRegularExpression("[A-Z]*")).toInt();
if (bulbWatts > 0)
return bulbWatts + 100;
else
Expand Down
2 changes: 1 addition & 1 deletion engine/src/scriptv4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ QString Script::data() const

QStringList Script::dataLines() const
{
QStringList result = m_data.split(QRegularExpression("(\r\n|\n\r|\r|\n)"));
QStringList result = m_data.split(QRegularExpression("(\\r\\n|\\n\\r|\\r|\\n)"));

while (result.count() && result.last().isEmpty())
result.takeLast();
Expand Down
2 changes: 1 addition & 1 deletion engine/test/rgbscript/rgbscript_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void RGBScript_Test::runScripts()
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QVERIFY(QRegExp("[a-z]*").exactMatch(baseName));
#else
QVERIFY(QRegularExpression("[a-z]*").match(baseName).hasMatch());
QVERIFY(QRegularExpression("[a-z]+").match(baseName).hasMatch());
#endif

#ifdef QT_QML_LIB
Expand Down
5 changes: 2 additions & 3 deletions fixtureeditor/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
* @{
*/

//! Prevent people from using ALL CAPS. It's fucking annoying.
//#define REGEXP_CAPS "(([^A-Z]*[A-Z]{5,}[^A-Z]+)*)"
#define REGEXP_CAPS ""
//! Prevent people from using ALL CAPS. It's fucking annoying. Allow max. 5 consecutive CAPS in a row
#define REGEXP_CAPS "[^A-Z]*[A-Z]{0,5}([^A-Z]+[A-Z]{0,5})*"
#define CAPS_VALIDATOR(parent) new QRegularExpressionValidator(QRegularExpression(REGEXP_CAPS), parent)

/** @} */
Expand Down
2 changes: 1 addition & 1 deletion ui/src/scripteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void ScriptEditor::slotCheckSyntax()
}
else
{
QStringList lines = scriptText.split(QRegularExpression("(\r\n|\n\r|\r|\n)"));
QStringList lines = scriptText.split(QRegularExpression("(\\r\\n|\\n\\r|\\r|\\n)"));
foreach(int line, errLines)
{
errResult.append(tr("Syntax error at line %1:\n%2\n\n").arg(line).arg(lines.at(line - 1)));
Expand Down

0 comments on commit 9b527ab

Please sign in to comment.