diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 87adfdc6e7b..15285e17ab3 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -25,9 +25,10 @@ #ifndef LMMS_AUTOMATABLE_MODEL_H #define LMMS_AUTOMATABLE_MODEL_H +#include #include #include -#include +#include #include "JournallingObject.h" #include "Model.h" diff --git a/include/EffectSelectDialog.h b/include/EffectSelectDialog.h index db8e60f0d1f..53e8dbe7e44 100644 --- a/include/EffectSelectDialog.h +++ b/include/EffectSelectDialog.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,10 +65,19 @@ class DualColumnFilterProxyModel : public QSortFilterProxyModel QString name = sourceModel()->data(nameIndex, Qt::DisplayRole).toString(); QString type = sourceModel()->data(typeIndex, Qt::DisplayRole).toString(); - QRegExp nameRegExp(filterRegExp()); - nameRegExp.setCaseSensitivity(Qt::CaseInsensitive); + // TODO: cleanup once we drop Qt5 support +#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0)) + QRegularExpression nameRegularExpression(filterRegularExpression()); + nameRegularExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + + bool nameFilterPassed = nameRegularExpression.match(name).capturedStart() != -1; +#else + QRegExp nameRegularExpression(filterRegExp()); + nameRegularExpression.setCaseSensitivity(Qt::CaseInsensitive); + + bool nameFilterPassed = nameRegularExpression.indexIn(name) != -1; +#endif - bool nameFilterPassed = nameRegExp.indexIn(name) != -1; bool typeFilterPassed = type.contains(m_effectTypeFilter, Qt::CaseInsensitive); return nameFilterPassed && typeFilterPassed; diff --git a/include/LadspaBase.h b/include/LadspaBase.h index 6569c5a309e..0a2b067d4f2 100644 --- a/include/LadspaBase.h +++ b/include/LadspaBase.h @@ -26,6 +26,8 @@ #ifndef LMMS_LADSPA_BASE_H #define LMMS_LADSPA_BASE_H +#include + #include "LadspaManager.h" #include "Plugin.h" @@ -75,7 +77,7 @@ inline Plugin::Descriptor::SubPluginFeatures::Key ladspaKeyToSubPluginKey( { Plugin::Descriptor::SubPluginFeatures::Key::AttributeMap m; QString file = _key.first; - m["file"] = file.remove( QRegExp( "\\.so$" ) ).remove( QRegExp( "\\.dll$" ) ); + m["file"] = file.remove(QRegularExpression("\\.so$")).remove(QRegularExpression("\\.dll$")); m["plugin"] = _key.second; return Plugin::Descriptor::SubPluginFeatures::Key( _desc, _name, m ); } diff --git a/plugins/CarlaBase/Carla.h b/plugins/CarlaBase/Carla.h index e04444f91b2..3d0e424a277 100644 --- a/plugins/CarlaBase/Carla.h +++ b/plugins/CarlaBase/Carla.h @@ -33,6 +33,7 @@ #include #include #include +#include // carla/source/includes #include "carlabase_export.h" @@ -89,8 +90,8 @@ class CarlaParamFloatModel : public FloatModel // From AutomatableModel.h, it's private there. inline static bool 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(); } inline void loadSettings(const QDomElement& element, const QString& name = QString("value")) override diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp index 46a211f9f75..fc46671528a 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp @@ -171,8 +171,7 @@ ladspa_key_t LadspaSubPluginFeatures::subPluginKeyToLadspaKey( const Key * _key ) { QString file = _key->attributes["file"]; - return( ladspa_key_t( file.remove( QRegExp( "\\.so$" ) ). - remove( QRegExp( "\\.dll$" ) ) + + return(ladspa_key_t(file.remove(QRegularExpression("\\.so$")).remove(QRegularExpression("\\.dll$")) + #ifdef LMMS_BUILD_WIN32 ".dll" #else diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index be38bcb7978..01fa6400b79 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -311,7 +311,7 @@ void ZynAddSubFxInstrument::loadFile( const QString & _file ) m_pluginMutex.unlock(); } - instrumentTrack()->setName( QFileInfo( _file ).baseName().replace( QRegExp( "^[0-9]{4}-" ), QString() ) ); + instrumentTrack()->setName(QFileInfo(_file).baseName().replace(QRegularExpression("^[0-9]{4}-"), QString())); m_modifiedControllers.clear(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index e46a864f897..c701f28e36d 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -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 ) diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index a520e6bc5c9..3c6309db85f 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #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 ); } diff --git a/src/core/RenderManager.cpp b/src/core/RenderManager.cpp index 9f619203903..d375b95ee5a 100644 --- a/src/core/RenderManager.cpp +++ b/src/core/RenderManager.cpp @@ -23,6 +23,7 @@ */ #include +#include #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); } diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 4156b9e79df..6bb8415bd45 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #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 diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index fa9be2a5055..a726dd5b989 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -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 && diff --git a/src/gui/modals/EffectSelectDialog.cpp b/src/gui/modals/EffectSelectDialog.cpp index 4e6427e8144..65976059fca 100644 --- a/src/gui/modals/EffectSelectDialog.cpp +++ b/src/gui/modals/EffectSelectDialog.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -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(); diff --git a/src/gui/modals/VersionedSaveDialog.cpp b/src/gui/modals/VersionedSaveDialog.cpp index 0c61df9f2ba..c8e1c682120 100644 --- a/src/gui/modals/VersionedSaveDialog.cpp +++ b/src/gui/modals/VersionedSaveDialog.cpp @@ -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 )