Replace QRegExp with QRegularExpression (#7133)
* replace QRegExp with QRegularExpression (find n replace) * follow up to fix errors * removed rpmalloc * Fix compilation for qt5, to be fixed when qt6 fully supported. Co-authored-by: Kevin Zander <veratil@gmail.com> * Added QtGlobal header for version finding fix * Use the other syntax to try fix compilation. * Check for 5.12 instead. * Fix the header * Attempt at fixing it further. * Use version checks properly in header file * Use QT_VERSION_CHECK macro in sources * Apply suggestions from messmerd's review Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com> --------- Co-authored-by: Kevin Zander <veratil@gmail.com> Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
@@ -97,8 +97,8 @@ bool AutomatableModel::isAutomated() const
|
||||
|
||||
bool AutomatableModel::mustQuoteName(const QString& name)
|
||||
{
|
||||
QRegExp reg("^[A-Za-z0-9._-]+$");
|
||||
return !reg.exactMatch(name);
|
||||
QRegularExpression reg("^[A-Za-z0-9._-]+$");
|
||||
return !reg.match(name).hasMatch();
|
||||
}
|
||||
|
||||
void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, const QString& name )
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QSaveFile>
|
||||
|
||||
#include "base64.h"
|
||||
@@ -973,8 +974,7 @@ void DataFile::upgrade_0_4_0_20080622()
|
||||
{
|
||||
QDomElement el = list.item( i ).toElement();
|
||||
QString s = el.attribute( "name" );
|
||||
s.replace( QRegExp( "^Beat/Baseline " ),
|
||||
"Beat/Bassline " );
|
||||
s.replace(QRegularExpression("^Beat/Baseline "), "Beat/Bassline");
|
||||
el.setAttribute( "name", s );
|
||||
}
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ void DataFile::upgrade_1_1_91()
|
||||
{
|
||||
QDomElement el = list.item( i ).toElement();
|
||||
QString s = el.attribute( "src" );
|
||||
s.replace( QRegExp("/samples/bassloopes/"), "/samples/bassloops/" );
|
||||
s.replace(QRegularExpression("/samples/bassloopes/"), "/samples/bassloops/");
|
||||
el.setAttribute( "src", s );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "RenderManager.h"
|
||||
|
||||
@@ -182,7 +183,7 @@ QString RenderManager::pathForTrack(const Track *track, int num)
|
||||
{
|
||||
QString extension = ProjectRenderer::getFileExtensionFromFormat( m_format );
|
||||
QString name = track->name();
|
||||
name = name.remove(QRegExp(FILENAME_FILTER));
|
||||
name = name.remove(QRegularExpression(FILENAME_FILTER));
|
||||
name = QString( "%1_%2%3" ).arg( num ).arg( name ).arg( extension );
|
||||
return QDir(m_outputPath).filePath(name);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "ComboBox.h"
|
||||
@@ -342,7 +342,7 @@ bool MicrotunerConfig::validateScaleForm()
|
||||
{
|
||||
if (line.isEmpty()) {continue;}
|
||||
if (line[0] == '!') {continue;} // comment
|
||||
QString firstSection = line.section(QRegExp("\\s+|/"), 0, 0, QString::SectionSkipEmpty);
|
||||
QString firstSection = line.section(QRegularExpression("\\s+|/"), 0, 0, QString::SectionSkipEmpty);
|
||||
if (firstSection.contains('.')) // cent mode
|
||||
{
|
||||
bool ok = true;
|
||||
@@ -357,7 +357,7 @@ bool MicrotunerConfig::validateScaleForm()
|
||||
if (!ok) {fail(tr("Numerator of an interval defined as a ratio cannot be converted to a number")); return false;}
|
||||
if (line.contains('/'))
|
||||
{
|
||||
den = line.split('/').at(1).section(QRegExp("\\s+"), 0, 0, QString::SectionSkipEmpty).toInt(&ok);
|
||||
den = line.split('/').at(1).section(QRegularExpression("\\s+"), 0, 0, QString::SectionSkipEmpty).toInt(&ok);
|
||||
}
|
||||
if (!ok) {fail(tr("Denominator of an interval defined as a ratio cannot be converted to a number")); return false;}
|
||||
if (num * den < 0) {fail(tr("Interval defined as a ratio cannot be negative")); return false;}
|
||||
@@ -390,7 +390,7 @@ bool MicrotunerConfig::validateKeymapForm()
|
||||
{
|
||||
if (line.isEmpty()) {continue;}
|
||||
if (line[0] == '!') {continue;} // comment
|
||||
QString firstSection = line.section(QRegExp("\\s+"), 0, 0, QString::SectionSkipEmpty);
|
||||
QString firstSection = line.section(QRegularExpression("\\s+"), 0, 0, QString::SectionSkipEmpty);
|
||||
if (firstSection == "x") {continue;} // not mapped
|
||||
// otherwise must contain a number
|
||||
bool ok = true;
|
||||
@@ -424,7 +424,7 @@ bool MicrotunerConfig::applyScale()
|
||||
{
|
||||
if (line.isEmpty()) {continue;}
|
||||
if (line[0] == '!') {continue;} // comment
|
||||
QString firstSection = line.section(QRegExp("\\s+|/"), 0, 0, QString::SectionSkipEmpty);
|
||||
QString firstSection = line.section(QRegularExpression("\\s+|/"), 0, 0, QString::SectionSkipEmpty);
|
||||
if (firstSection.contains('.')) // cent mode
|
||||
{
|
||||
newIntervals.emplace_back(firstSection.toFloat());
|
||||
@@ -435,7 +435,7 @@ bool MicrotunerConfig::applyScale()
|
||||
num = firstSection.toInt();
|
||||
if (line.contains('/'))
|
||||
{
|
||||
den = line.split('/').at(1).section(QRegExp("\\s+"), 0, 0, QString::SectionSkipEmpty).toInt();
|
||||
den = line.split('/').at(1).section(QRegularExpression("\\s+"), 0, 0, QString::SectionSkipEmpty).toInt();
|
||||
}
|
||||
newIntervals.emplace_back(num, den);
|
||||
}
|
||||
@@ -470,7 +470,7 @@ bool MicrotunerConfig::applyKeymap()
|
||||
{
|
||||
if (line.isEmpty()) {continue;}
|
||||
if (line[0] == '!') {continue;} // comment
|
||||
QString firstSection = line.section(QRegExp("\\s+"), 0, 0, QString::SectionSkipEmpty);
|
||||
QString firstSection = line.section(QRegularExpression("\\s+"), 0, 0, QString::SectionSkipEmpty);
|
||||
if (firstSection == "x")
|
||||
{
|
||||
newMap.push_back(-1); // not mapped
|
||||
|
||||
@@ -420,7 +420,7 @@ void InstrumentTrackWindow::saveSettingsBtnClicked()
|
||||
sfd.setDirectory(presetRoot + m_track->instrumentName());
|
||||
sfd.setFileMode( FileDialog::AnyFile );
|
||||
QString fname = m_track->name();
|
||||
sfd.selectFile(fname.remove(QRegExp(FILENAME_FILTER)));
|
||||
sfd.selectFile(fname.remove(QRegularExpression(FILENAME_FILTER)));
|
||||
sfd.setDefaultSuffix( "xpf");
|
||||
|
||||
if( sfd.exec() == QDialog::Accepted &&
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QRegularExpression>
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -126,7 +127,12 @@ EffectSelectDialog::EffectSelectDialog(QWidget* parent) :
|
||||
|
||||
m_filterEdit = new QLineEdit(this);
|
||||
connect(m_filterEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||
// TODO: Cleanup when we don't support Qt5 anymore
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
|
||||
m_model.setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));
|
||||
#else
|
||||
m_model.setFilterRegExp(QRegExp(text, Qt::CaseInsensitive));
|
||||
#endif
|
||||
});
|
||||
connect(m_filterEdit, &QLineEdit::textChanged, this, &EffectSelectDialog::updateSelection);
|
||||
m_filterEdit->setFocus();
|
||||
|
||||
@@ -89,9 +89,9 @@ VersionedSaveDialog::VersionedSaveDialog( QWidget *parent,
|
||||
|
||||
bool VersionedSaveDialog::changeFileNameVersion(QString &fileName, bool increment )
|
||||
{
|
||||
static QRegExp regexp( "[- ]\\d+(\\.\\w+)?$" );
|
||||
static QRegularExpression regex( "[- ]\\d+(\\.\\w+)?$" );
|
||||
|
||||
int idx = regexp.indexIn( fileName );
|
||||
int idx = regex.match(fileName).capturedStart();
|
||||
// For file names without extension (no ".mmpz")
|
||||
int insertIndex = fileName.lastIndexOf( '.' );
|
||||
if ( insertIndex < idx+1 )
|
||||
|
||||
Reference in New Issue
Block a user