diff --git a/libmscore/CMakeLists.txt b/libmscore/CMakeLists.txt index a0caf1fd7519f..e693b3e631aa8 100644 --- a/libmscore/CMakeLists.txt +++ b/libmscore/CMakeLists.txt @@ -50,7 +50,7 @@ add_library ( harmony.h hook.h icon.h image.h imageStore.h iname.h input.h instrchange.h instrtemplate.h instrument.h interval.h jump.h key.h keylist.h keysig.h lasso.h layout.h layoutbreak.h ledgerline.h letring.h line.h location.h lyrics.h marker.h mcursor.h measure.h measurebase.h mscore.h mscoreview.h musescoreCore.h navigate.h note.h notedot.h - noteevent.h noteline.h ossia.h ottava.h page.h palmmute.h part.h pedal.h pitch.h pitchspelling.h pitchvalue.h + noteevent.h ossia.h ottava.h page.h palmmute.h part.h pedal.h pitch.h pitchspelling.h pitchvalue.h pos.h property.h range.h read206.h realizedharmony.h rehearsalmark.h repeat.h repeatlist.h rest.h revisions.h score.h scoreOrder.h scoreElement.h segment.h segmentlist.h select.h sequencer.h shadownote.h shape.h sig.h slur.h slurtie.h spacer.h spanner.h spannermap.h spatium.h staff.h stafflines.h staffstate.h stafftext.h stafftextbase.h stafftype.h stafftypechange.h stafftypelist.h stem.h @@ -89,7 +89,7 @@ add_library ( paste.cpp bsymbol.cpp marker.cpp jump.cpp stemslash.cpp ledgerline.cpp synthesizerstate.cpp mcursor.cpp groups.cpp mscoreview.cpp - noteline.cpp spannermap.cpp + spannermap.cpp bagpembell.cpp ambitus.cpp keylist.cpp scoreElement.cpp scoreOrder.cpp shape.cpp systemdivider.cpp midimapping.cpp stafflines.cpp sticking.cpp diff --git a/libmscore/element.cpp b/libmscore/element.cpp index 55ff2690de9f3..837fd0f1df16f 100644 --- a/libmscore/element.cpp +++ b/libmscore/element.cpp @@ -56,7 +56,6 @@ #include "mscore.h" #include "notedot.h" #include "note.h" -#include "noteline.h" #include "ossia.h" #include "ottava.h" #include "page.h" @@ -748,7 +747,7 @@ bool Element::readProperties(XmlReader& e) } #ifndef NDEBUG else { - for (ScoreElement* eee : *_links) { + for (ScoreElement* eee : qAsConst(*_links)) { Element* ee = static_cast(eee); if (ee->type() != type()) { qFatal("link %s(%d) type mismatch %s linked to %s", @@ -1061,7 +1060,6 @@ Element* Element::create(ElementType type, Score* score) case ElementType::VOLTA: return new Volta(score); case ElementType::OTTAVA: return new Ottava(score); case ElementType::TEXTLINE: return new TextLine(score); - case ElementType::NOTELINE: return new NoteLine(score); case ElementType::TRILL: return new Trill(score); case ElementType::LET_RING: return new LetRing(score); case ElementType::VIBRATO: return new Vibrato(score); diff --git a/libmscore/noteline.cpp b/libmscore/noteline.cpp deleted file mode 100644 index f1a4a0cd41403..0000000000000 --- a/libmscore/noteline.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//============================================================================= -// MuseScore -// Music Composition & Notation -// -// Copyright (C) 2002-2011 Werner Schweer -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 -// as published by the Free Software Foundation and appearing in -// the file LICENCE.GPL -//============================================================================= - -#include "noteline.h" -#include "textline.h" - -namespace Ms { - -NoteLine::NoteLine(Score* s) - : TextLineBase(s) - { -//TODO-ws init(); - } - -NoteLine::NoteLine(const NoteLine& nl) - : TextLineBase(nl) - { - } - -//--------------------------------------------------------- -// createLineSegment -//--------------------------------------------------------- - -LineSegment* NoteLine::createLineSegment() - { - TextLineSegment* seg = new TextLineSegment(this, score()); - seg->setTrack(track()); - return seg; - } - - -} // namespace Ms - diff --git a/libmscore/noteline.h b/libmscore/noteline.h deleted file mode 100644 index 8cd6f887e98ca..0000000000000 --- a/libmscore/noteline.h +++ /dev/null @@ -1,48 +0,0 @@ -//============================================================================= -// MuseScore -// Music Composition & Notation -// -// Copyright (C) 2002-2011 Werner Schweer -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 -// as published by the Free Software Foundation and appearing in -// the file LICENCE.GPL -//============================================================================= - -#ifndef __NOTELINE_H__ -#define __NOTELINE_H__ - -#include "textlinebase.h" - -namespace Ms { - -class Note; - -//--------------------------------------------------------- -// @@ NoteLine -//--------------------------------------------------------- - -class NoteLine final : public TextLineBase { - Note* _startNote; - Note* _endNote; - - public: - NoteLine(Score* s); - NoteLine(const NoteLine&); - ~NoteLine() {} - - NoteLine* clone() const override { return new NoteLine(*this); } - ElementType type() const override { return ElementType::NOTELINE; } - - void setStartNote(Note* n) { _startNote = n; } - Note* startNote() const { return _startNote; } - void setEndNote(Note* n) { _endNote = n; } - Note* endNote() const { return _endNote; } - LineSegment* createLineSegment() override; - }; - - -} // namespace Ms -#endif - diff --git a/libmscore/scoreElement.cpp b/libmscore/scoreElement.cpp index def95624ae8cd..e0605d17a1860 100644 --- a/libmscore/scoreElement.cpp +++ b/libmscore/scoreElement.cpp @@ -10,15 +10,13 @@ // the file LICENCE.GPL //============================================================================= -#include "scoreElement.h" -#include "score.h" -#include "undo.h" -#include "xml.h" -#include "bracket.h" #include "bracketItem.h" #include "measure.h" -#include "spanner.h" #include "musescoreCore.h" +#include "score.h" +#include "scoreElement.h" +#include "undo.h" +#include "xml.h" namespace Ms { @@ -114,7 +112,6 @@ static const ElementName elementNames[] = { { ElementType::PALM_MUTE, "PalmMute", QT_TRANSLATE_NOOP("elementName", "Palm Mute") }, { ElementType::TEXTLINE, "TextLine", QT_TRANSLATE_NOOP("elementName", "Text Line") }, { ElementType::TEXTLINE_BASE, "TextLineBase", QT_TRANSLATE_NOOP("elementName", "Text Line Base") }, // remove - { ElementType::NOTELINE, "NoteLine", QT_TRANSLATE_NOOP("elementName", "Note Line") }, { ElementType::LYRICSLINE, "LyricsLine", QT_TRANSLATE_NOOP("elementName", "Melisma Line") }, { ElementType::GLISSANDO, "Glissando", QT_TRANSLATE_NOOP("elementName", "Glissando") }, { ElementType::BRACKET, "Bracket", QT_TRANSLATE_NOOP("elementName", "Bracket") }, diff --git a/libmscore/scoreElement.h b/libmscore/scoreElement.h index bb96dd41dbe29..a9eb7cab0761c 100644 --- a/libmscore/scoreElement.h +++ b/libmscore/scoreElement.h @@ -97,7 +97,6 @@ class PedalSegment; class LedgerLine; class Icon; class VoltaSegment; -class NoteLine; class Trill; class TrillSegment; class Symbol; @@ -323,7 +322,6 @@ class ScoreElement { CONVERT(LedgerLine, LEDGER_LINE) CONVERT(Icon, ICON) CONVERT(VoltaSegment, VOLTA_SEGMENT) - CONVERT(NoteLine, NOTELINE) CONVERT(Trill, TRILL) CONVERT(TrillSegment, TRILL_SEGMENT) CONVERT(LetRing, LET_RING) @@ -391,7 +389,6 @@ class ScoreElement { bool isTextLineBase() const { return isHairpin() || isLetRing() - || isNoteLine() || isOttava() || isPalmMute() || isPedal() @@ -578,7 +575,6 @@ static inline const a* to##a(const ScoreElement* e) { Q_ASSERT(e == 0 || e->is## CONVERT(LedgerLine) CONVERT(Icon) CONVERT(VoltaSegment) - CONVERT(NoteLine) CONVERT(Trill) CONVERT(TrillSegment) CONVERT(LetRing) diff --git a/libmscore/select.cpp b/libmscore/select.cpp index 10c3732a9ceec..a958679f73a34 100644 --- a/libmscore/select.cpp +++ b/libmscore/select.cpp @@ -17,8 +17,9 @@ #include "global/log.h" -#include "mscore.h" +#include "accidental.h" #include "arpeggio.h" +#include "articulation.h" #include "barline.h" #include "beam.h" #include "chord.h" @@ -31,33 +32,29 @@ #include "fret.h" #include "hook.h" #include "input.h" -#include "limits.h" #include "lyrics.h" #include "measure.h" +#include "mscore.h" #include "note.h" #include "notedot.h" #include "page.h" +#include "part.h" #include "rest.h" #include "score.h" #include "segment.h" #include "select.h" #include "sig.h" -#include "slur.h" +#include "staff.h" +#include "stafftext.h" #include "stem.h" #include "stemslash.h" -#include "tie.h" +#include "sticking.h" #include "system.h" -#include "text.h" +#include "tie.h" #include "tremolo.h" #include "tuplet.h" #include "utils.h" #include "xml.h" -#include "staff.h" -#include "part.h" -#include "accidental.h" -#include "articulation.h" -#include "stafftext.h" -#include "sticking.h" namespace Ms { @@ -417,7 +414,7 @@ bool SelectionFilter::canSelect(const Element* e) const return isFiltered(SelectionFilterType::BREATH); if (e->isTextBase()) // only TEXT, INSTRCHANGE and STAFFTEXT are caught here, rest are system thus not in selection return isFiltered(SelectionFilterType::OTHER_TEXT); - if (e->isSLine()) // NoteLine, Volta + if (e->isSLine()) // Volta return isFiltered(SelectionFilterType::OTHER_LINE); if (e->isTremolo()) return isFiltered(SelectionFilterType::TREMOLO); @@ -487,7 +484,7 @@ void Selection::appendChord(Chord* chord) if (note->accidental()) _el.append(note->accidental()); for (Element* el : note->el()) appendFiltered(el); - for (NoteDot* dot : note->dots()) + for (NoteDot* dot : qAsConst(note->dots())) _el.append(dot); if (note->tieFor() && (note->tieFor()->endElement() != 0)) { @@ -605,10 +602,10 @@ void Selection::updateSelectedElements() } if (e->isChord()) { Chord* chord = toChord(e); - for (Chord* graceNote : chord->graceNotes()) + for (Chord* graceNote : qAsConst(chord->graceNotes())) if (canSelect(graceNote)) appendChord(graceNote); appendChord(chord); - for (Articulation* art : chord->articulations()) + for (Articulation* art : qAsConst(chord->articulations())) appendFiltered(art); } else { @@ -710,7 +707,7 @@ void Selection::dump() case SelState::RANGE: qDebug("RANGE"); break; case SelState::LIST: qDebug("LIST"); break; } - for (const Element* e : _el) + for (const Element* e : qAsConst(_el)) qDebug(" %p %s", e, e->name()); } @@ -842,10 +839,10 @@ QByteArray Selection::staffMimeData() const Fraction ticks = tickEnd() - tickStart(); int staves = staffEnd() - staffStart(); if (!MScore::testMode) { - xml.stag(QString("StaffList version=\"" MSC_VERSION "\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString()).arg(ticks.toString()).arg(staffStart()).arg(staves)); + xml.stag(QString("StaffList version=\"" MSC_VERSION "\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString(), ticks.toString()).arg(staffStart()).arg(staves)); } else { - xml.stag(QString("StaffList version=\"2.00\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString()).arg(ticks.toString()).arg(staffStart()).arg(staves)); + xml.stag(QString("StaffList version=\"2.00\" tick=\"%1\" len=\"%2\" staff=\"%3\" staves=\"%4\"").arg(tickStart().toString(), ticks.toString()).arg(staffStart()).arg(staves)); } Segment* seg1 = _startSegment; Segment* seg2 = _endSegment; @@ -977,7 +974,6 @@ Enabling copying of more element types requires enabling pasting in Score::paste case ElementType::PEDAL: case ElementType::TRILL: case ElementType::TEXTLINE: - case ElementType::NOTELINE: case ElementType::SEGMENT: case ElementType::SYSTEM: case ElementType::COMPOUND: @@ -1148,7 +1144,7 @@ std::vector Selection::noteList(int selTrack) const continue; Chord* c = toChord(e); nl.insert(nl.end(), c->notes().begin(), c->notes().end()); - for (Chord* g : c->graceNotes()) { + for (Chord* g : qAsConst(c->graceNotes())) { nl.insert(nl.end(), g->notes().begin(), g->notes().end()); } } diff --git a/libmscore/types.h b/libmscore/types.h index afff0c9e46b9a..1b967860b23dc 100644 --- a/libmscore/types.h +++ b/libmscore/types.h @@ -119,7 +119,6 @@ enum class ElementType { PALM_MUTE, TEXTLINE, TEXTLINE_BASE, - NOTELINE, LYRICSLINE, GLISSANDO, BRACKET, diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 9ccff72637a76..a9d0c21759870 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -384,7 +384,7 @@ void MuseScore::closeEvent(QCloseEvent* ev) { unloadPlugins(); QList removeList; - for (MasterScore* score : scoreList) { + for (MasterScore* score : qAsConst(scoreList)) { // Prompt the user to save the score if it's "dirty" (has unsaved changes) or if it's newly created but non-empty. if (checkDirty(score)) { // The user has canceled out entirely, so ignore the close event. @@ -405,7 +405,7 @@ void MuseScore::closeEvent(QCloseEvent* ev) } writeSessionFile(true); - for (MasterScore* score : scoreList) { + for (MasterScore* score : qAsConst(scoreList)) { if (!score->tmpName().isEmpty()) { QFile f(score->tmpName()); f.remove(); @@ -659,7 +659,7 @@ bool MuseScore::importExtension(QString path) MQZipReader zipFile(path); // compute total unzipped size qint64 totalZipSize = 0; - for (auto fi : zipFile.fileInfoList()) + for (auto& fi : zipFile.fileInfoList()) totalZipSize += fi.size; // check if extension path is writable and has enough space @@ -681,7 +681,7 @@ bool MuseScore::importExtension(QString path) bool hasAlienDirectory = false; bool hasAlienFiles = false; QSet acceptableFolders = { Extension::sfzsDir, Extension::soundfontsDir, Extension::templatesDir, Extension::instrumentsDir, Extension::workspacesDir }; - for (auto fi : zipFile.fileInfoList()) { + for (auto& fi : zipFile.fileInfoList()) { if (fi.filePath == "metadata.json") hasMetadata = true; else { @@ -735,32 +735,28 @@ bool MuseScore::importExtension(QString path) // Check if extension is already installed, ask for uninstall QDir dir(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)); auto dirList = dir.entryList(QStringList(extensionId), QDir::Dirs | QDir::NoDotAndDotDot); - bool newerVersion = false; if (dirList.contains(extensionId)) { - QString extDirName = QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId); + QString extDirName = QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId); QDir extDir(extDirName); auto versionDirList = extDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); if (versionDirList.size() > 0) { // potentially other versions // is there a more recent version? - for (auto versionDir : versionDirList) { + for (auto& versionDir : versionDirList) { if (compareVersion(version, versionDir)) { qDebug() << "There is a newer version. We don't install"; if (!MScore::noGui) QMessageBox::critical(mscore, QWidget::tr("Import Extension File"), QWidget::tr("A newer version is already installed")); - newerVersion = true; return false; } } } - if (!newerVersion) { - qDebug() << "found already install extension without newer version: deleting it"; - QDir d(QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId)); - if (!d.removeRecursively()) { - if (!MScore::noGui) - QMessageBox::critical(mscore, QWidget::tr("Import Extension File"), QWidget::tr("Error while deleting previous version of the extension: %1").arg(extensionId)); - return false; - } + qDebug() << "found already install extension without newer version: deleting it"; + QDir d(QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId)); + if (!d.removeRecursively()) { + if (!MScore::noGui) + QMessageBox::critical(mscore, QWidget::tr("Import Extension File"), QWidget::tr("Error while deleting previous version of the extension: %1").arg(extensionId)); + return false; } } @@ -780,7 +776,7 @@ bool MuseScore::importExtension(QString path) MQZipReader* zipFile3 = new MQZipReader(path); // Unzip the extension asynchronously - QFuture futureUnzip = QtConcurrent::run(zipFile3, &MQZipReader::extractAll, QString("%1/%2/%3").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version)); + QFuture futureUnzip = QtConcurrent::run(zipFile3, &MQZipReader::extractAll, QString("%1/%2/%3").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version)); futureWatcherUnzip.setFuture(futureUnzip); if (!MScore::noGui) infoMsgBox->exec(); @@ -802,7 +798,7 @@ bool MuseScore::importExtension(QString path) auto loadSoundFontAsync = [&]() { // After install: add sfz to zerberus - QDir sfzDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::sfzsDir)); + QDir sfzDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::sfzsDir)); if (sfzDir.exists()) { // get all sfz files QDirIterator it(sfzDir.absolutePath(), QStringList("*.sfz"), QDir::Files, QDirIterator::Subdirectories); @@ -823,7 +819,7 @@ bool MuseScore::importExtension(QString path) } // After install: add soundfont to fluid - QDir sfDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::soundfontsDir)); + QDir sfDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::soundfontsDir)); if (sfDir.exists()) { // get all soundfont files QStringList filters("*.sf2"); @@ -836,7 +832,7 @@ bool MuseScore::importExtension(QString path) } sfs.sort(); Synthesizer* s = synti->synthesizer("Fluid"); - for (auto sf : sfs) { + for (auto& sf : sfs) { s->addSoundFont(sf); } if (!sfs.isEmpty()) @@ -859,7 +855,7 @@ bool MuseScore::importExtension(QString path) } // after install: refresh workspaces if needed - QDir workspacesDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::workspacesDir)); + QDir workspacesDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::workspacesDir)); if (workspacesDir.exists() && !MScore::noGui) { auto wsList = workspacesDir.entryInfoList(QStringList("*.workspace"), QDir::Files); if (!wsList.isEmpty()) { @@ -879,7 +875,7 @@ bool MuseScore::uninstallExtension(QString extensionId) { QString version = Extension::getLatestVersion(extensionId); // Before install: remove sfz from zerberus - QDir sfzDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::sfzsDir)); + QDir sfzDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::sfzsDir)); if (sfzDir.exists()) { // get all sfz files QDirIterator it(sfzDir.absolutePath(), QStringList("*.sfz"), QDir::Files, QDirIterator::Subdirectories); @@ -894,7 +890,7 @@ bool MuseScore::uninstallExtension(QString extensionId) s->gui()->synthesizerChanged(); } // Before install: remove soundfont from fluid - QDir sfDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::soundfontsDir)); + QDir sfDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::soundfontsDir)); if (sfDir.exists()) { // get all soundfont files QStringList filters("*.sf2"); @@ -912,7 +908,7 @@ bool MuseScore::uninstallExtension(QString extensionId) s->gui()->synthesizerChanged(); } bool refreshWorkspaces = false; - QDir workspacesDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId).arg(version).arg(Extension::workspacesDir)); + QDir workspacesDir(QString("%1/%2/%3/%4").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId, version).arg(Extension::workspacesDir)); if (workspacesDir.exists()) { auto wsList = workspacesDir.entryInfoList(QStringList("*.workspace"), QDir::Files); if (!wsList.isEmpty()) @@ -920,7 +916,7 @@ bool MuseScore::uninstallExtension(QString extensionId) } // delete directories - QDir extensionDir(QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS)).arg(extensionId)); + QDir extensionDir(QString("%1/%2").arg(preferences.getString(PREF_APP_PATHS_MYEXTENSIONS), extensionId)); extensionDir.removeRecursively(); // update UI @@ -932,7 +928,6 @@ bool MuseScore::uninstallExtension(QString extensionId) const auto curWorkspaceName = WorkspacesManager::currentWorkspace()->name(); WorkspacesManager::refreshWorkspaces(); emit workspacesChanged(); - auto ws = WorkspacesManager::workspaces(); //If current worksapce is alive, do nothing //Select first available workspace in the list otherwise bool curWorkspaceDisappeared = false; @@ -998,7 +993,7 @@ void MuseScore::populateFileOperations() zoomBox->setItemText(static_cast(ZoomIndex::ZOOM_FREE), zoomBoxState.second); } - connect(zoomBox, SIGNAL(zoomChanged(const ZoomIndex, const qreal)), SLOT(zoomBoxChanged(const ZoomIndex, const qreal))); + connect(zoomBox, SIGNAL(zoomChanged(ZoomIndex,qreal)), SLOT(zoomBoxChanged(ZoomIndex,qreal))); fileTools->addWidget(zoomBox); viewModeCombo = new QComboBox(this); @@ -1133,7 +1128,7 @@ MuseScore::MuseScore() if (enableExperimental) { layerSwitch = new QComboBox(this); layerSwitch->setToolTip(tr("Switch layer")); - connect(layerSwitch, SIGNAL(activated(const QString&)), SLOT(switchLayer(const QString&))); + connect(layerSwitch, SIGNAL(activated(QString)), SLOT(switchLayer(QString))); playMode = new QComboBox(this); playMode->addItem(tr("Synthesizer")); playMode->addItem(tr("Audio track")); @@ -2635,11 +2630,11 @@ void MuseScore::reloadInstrumentTemplates() // load instrument templates from extension QStringList extensionDir = Extension::getDirectoriesByType(Extension::instrumentsDir); QStringList filter("*.xml"); - for (QString s : extensionDir) { + for (const QString& s : qAsConst(extensionDir)) { QDir extDir(s); extDir.setNameFilters(filter); auto instFiles = extDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::Readable); - for (auto instFile : instFiles) + for (auto& instFile : instFiles) loadInstrumentTemplates(instFile.absoluteFilePath()); } @@ -2953,7 +2948,7 @@ void MuseScore::dragEnterEvent(QDragEnterEvent* event) const QMimeData* dta = event->mimeData(); if (dta->hasUrls()) { QListul = event->mimeData()->urls(); - for (const QUrl& u : ul) { + for (const QUrl& u : qAsConst(ul)) { if (MScore::debugMode) qDebug("drag Url: %s scheme <%s>", qPrintable(u.toString()), qPrintable(u.scheme())); if (u.scheme() == "file") { @@ -3485,7 +3480,7 @@ void loadTranslation(QString filename, QString _localeName) void setMscoreLocale(QString _localeName) { - for (QTranslator* t : translatorList) { + for (QTranslator* t : qAsConst(translatorList)) { qApp->removeTranslator(t); delete t; } @@ -3655,7 +3650,7 @@ static bool doConvert(Score* cs, const QJsonArray& outFiles, QString plugin) // convert parts QString fnbeg = fns[0].toString(); QString fnend = fns[1].toString(); - for (Excerpt* e : cs->excerpts()) { + for (Excerpt* e : qAsConst(cs->excerpts())) { Score* pScore = e->partScore(); QString partfn = fnbeg + mscore->saveFilename(pScore->title()) + fnend; fprintf(stderr, "\tpart <%s>\n", qPrintable(partfn)); @@ -3703,7 +3698,7 @@ static bool doConvert(Score *cs, const QString& fn) if (cs->excerpts().size() == 0) { auto excerpts = Excerpt::createAllExcerpt(cs->masterScore()); - for (Excerpt* e : excerpts) { + for (Excerpt* e : qAsConst(excerpts)) { Score* nscore = new Score(e->oscore()); e->setPartScore(nscore); nscore->style().set(Sid::createMultiMeasureRests, true); @@ -3715,7 +3710,7 @@ static bool doConvert(Score *cs, const QString& fn) } QList scores; scores.append(cs); - for (Excerpt* e : cs->excerpts()) + for (Excerpt* e : qAsConst(cs->excerpts())) scores.append(e->partScore()); return mscore->savePdf(scores, fn); } @@ -3725,7 +3720,7 @@ static bool doConvert(Score *cs, const QString& fn) if (cs->excerpts().size() == 0) { auto excerpts = Excerpt::createAllExcerpt(cs->masterScore()); - for (Excerpt* e: excerpts) { + for (Excerpt* e: qAsConst(excerpts)) { Score* nscore = new Score(e->oscore()); e->setPartScore(nscore); nscore->setExcerpt(e); @@ -3741,7 +3736,7 @@ static bool doConvert(Score *cs, const QString& fn) return false; int idx = 0; int padding = QString("%1").arg(cs->excerpts().size()).size(); - for (Excerpt* e: cs->excerpts()) { + for (Excerpt* e: qAsConst(cs->excerpts())) { QString suffix = QString("__excerpt__%1.png").arg(idx, padding, 10, QLatin1Char('0')); QString excerptFn = fn.left(fn.size() - 4) + suffix; if (!mscore->savePng(e->partScore(), excerptFn)) @@ -3829,7 +3824,7 @@ static bool doProcessJob(QString jsonFile) return false; } QJsonArray a = doc.array(); - for (const auto i : a) { + for (const auto& i : qAsConst(a)) { QString inFile; QJsonArray outFiles; QString plugin; @@ -4838,7 +4833,7 @@ void MuseScore::play(Element* e) const if (cc != -1) seq->sendEvent(NPlayEvent(ME_CONTROLLER, channel, cc, 80)); - for (int pitch : pitches) + for (int& pitch : pitches) seq->startNote(channel, pitch, 80, 0); seq->startNoteTimer(MScore::defaultPlayDuration); } @@ -4883,9 +4878,7 @@ void MuseScore::play(Element* e, int pitch) const void MuseScore::reportBug(QString medium) { QString url = QString("https://github.com/Jojo-Schmitz/MuseScore/issues") - .arg(revision()) - .arg(getLocaleISOCode()) - .arg(getUtmParameters(medium)); + .arg(revision(), getLocaleISOCode(), getUtmParameters(medium)); QDesktopServices::openUrl(QUrl(url.trimmed())); } @@ -4919,9 +4912,7 @@ void MuseScore::leaveFeedback(QString medium) QString MuseScore::getUtmParameters(QString medium) const { return QString("utm_source=desktop&utm_medium=%1&utm_content=%2&utm_campaign=MuseScore%3") - .arg(medium) - .arg(rev.trimmed()) - .arg(QString(VERSION)); + .arg(medium, rev.trimmed(), QString(VERSION)); } //--------------------------------------------------------- @@ -5261,7 +5252,7 @@ void MuseScore::autoSaveTimerTimeout() ScoreLoad sl; //disable debug message "no active command" - for (MasterScore* s : scoreList) { + for (MasterScore* s : qAsConst(scoreList)) { if (s->autosaveDirty()) { qDebug("<%s>", qPrintable(s->fileInfo()->completeBaseName())); QString tmp = s->tmpName(); @@ -5553,8 +5544,8 @@ void MuseScore::showPianoKeyboard(bool visible) QAction* a = getAction("toggle-piano"); _pianoTools = new PianoTools(this); addDockWidget(Qt::BottomDockWidgetArea, _pianoTools); - connect(_pianoTools, SIGNAL(keyPressed(int, bool, int)), SLOT(midiNoteReceived(int, bool, int))); - connect(_pianoTools, SIGNAL(keyReleased(int, bool, int)), SLOT(midiNoteReceived(int, bool, int))); + connect(_pianoTools, SIGNAL(keyPressed(int,bool,int)), SLOT(midiNoteReceived(int,bool,int))); + connect(_pianoTools, SIGNAL(keyReleased(int,bool,int)), SLOT(midiNoteReceived(int,bool,int))); connect(_pianoTools, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); } if (visible) { @@ -5810,12 +5801,12 @@ void MuseScore::selectElementDialog(Element* e) if (sd.doReplace()) { score->select(0, SelectType::SINGLE, 0); - for (Note* ee : pattern.el) + for (Note* ee : qAsConst(pattern.el)) score->select(ee, SelectType::ADD, 0); } else if (sd.doSubtract()) { QList sl(score->selection().elements()); - for (Note* ee : pattern.el) + for (Note* ee : qAsConst(pattern.el)) sl.removeOne(ee); score->select(0, SelectType::SINGLE, 0); for (Element* ee : sl) @@ -5823,7 +5814,7 @@ void MuseScore::selectElementDialog(Element* e) } else if (sd.doAdd()) { QList sl(score->selection().elements()); - for (Note* ee : pattern.el) { + for (Note* ee : qAsConst(pattern.el)) { if(!sl.contains(ee)) score->select(ee, SelectType::ADD, 0); } @@ -5843,12 +5834,12 @@ void MuseScore::selectElementDialog(Element* e) if (sd.doReplace()) { score->select(0, SelectType::SINGLE, 0); - for (Element* ee : pattern.el) + for (Element* ee : qAsConst(pattern.el)) score->select(ee, SelectType::ADD, 0); } else if (sd.doSubtract()) { QList sl(score->selection().elements()); - for (Element* ee : pattern.el) + for (Element* ee : qAsConst(pattern.el)) sl.removeOne(ee); score->select(0, SelectType::SINGLE, 0); for (Element* ee : sl) @@ -5856,7 +5847,7 @@ void MuseScore::selectElementDialog(Element* e) } else if (sd.doAdd()) { QList sl(score->selection().elements()); - for (Element* ee : pattern.el) { + for (Element* ee : qAsConst(pattern.el)) { if(!sl.contains(ee)) score->select(ee, SelectType::ADD, 0); } @@ -7020,7 +7011,7 @@ QFileInfoList MuseScore::recentScores() const QFileInfo fi(s); bool alreadyLoaded = false; QString fp = fi.canonicalFilePath(); - for (Score* sc : mscore->scores()) { + for (Score* sc : qAsConst(mscore->scores())) { if ((sc->masterScore()->fileInfo()->canonicalFilePath() == fp) || (sc->importedFilePath() == fp)) { alreadyLoaded = true; break; @@ -7040,7 +7031,7 @@ QMenu* MuseScore::createPopupMenu() { QMenu* m = QMainWindow::createPopupMenu(); QList al = m->actions(); - for (QAction* a : al) { + for (QAction* a : qAsConst(al)) { // textTool visibility is handled differentlyr if (_textTools && a->text() == _textTools->windowTitle()) m->removeAction(a); @@ -7218,8 +7209,10 @@ bool MuseScore::saveMp3(Score* score, QIODevice* device, bool& wasCanceled) if (synti) score->masterScore()->rebuildAndUpdateExpressive(synti->synthesizer("Fluid")); - if (events.empty()) + if (events.empty()) { + delete[] bufferOut; return false; + } } QProgressDialog progress(this); @@ -7251,7 +7244,7 @@ bool MuseScore::saveMp3(Score* score, QIODevice* device, bool& wasCanceled) // // init instruments // - for (Part* part : score->parts()) { + for (Part* part : qAsConst(score->parts())) { const InstrumentList* il = part->instruments(); for (auto i = il->begin(); i!= il->end(); i++) { for (const Channel* channel : i->second->channel()) { @@ -7332,7 +7325,7 @@ bool MuseScore::saveMp3(Score* score, QIODevice* device, bool& wasCanceled) *l++ = *sp++; *r++ = *sp++; } - playTime += frames; + //playTime += frames; } if (pass == 1) { @@ -7455,9 +7448,9 @@ void MuseScore::updateUiStyleAndTheme() #endif #if defined(WIN_PORTABLE) - QString wd = QDir::cleanPath(QString("%1/../../../Data/%2").arg(QCoreApplication::applicationDirPath()).arg(QCoreApplication::applicationName())); + QString wd = QDir::cleanPath(QString("%1/../../../Data/%2").arg(QCoreApplication::applicationDirPath(), QCoreApplication::applicationName())); #else - QString wd = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).arg(QCoreApplication::applicationName()); + QString wd = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), QCoreApplication::applicationName()); #endif // set UI Color Palette @@ -7875,7 +7868,7 @@ MuseScoreApplication::CommandLineParseResult MuseScoreApplication::parseCommandL if (app && !converterMode && !pluginMode) { if (!argv.isEmpty()) { int ok = true; - for (const QString& message : argv) { + for (const QString& message : qAsConst(argv)) { QFileInfo fi(message); if (!app->sendMessage(fi.absoluteFilePath())) { ok = false; @@ -8260,8 +8253,8 @@ void MuseScore::init(QStringList& argv) else { showSplashMessage(sc, tr("Initializing main window…")); mscore->readSettings(); - QObject::connect(qApp, SIGNAL(messageReceived(const QString&)), - mscore, SLOT(handleMessage(const QString&))); + QObject::connect(qApp, SIGNAL(messageReceived(QString&)), + mscore, SLOT(handleMessage(QString&))); static_cast(qApp)->setActivationWindow(mscore, false); // count filenames specified on the command line @@ -8382,7 +8375,7 @@ bool MuseScore::saveScoreParts(const QString& inFilePath, const QString& outFile // if no parts, generate parts from existing instruments if (score->excerpts().isEmpty()) { auto excerpts = Excerpt::createAllExcerpt(score); - for (Excerpt* e : excerpts) { + for (Excerpt* e : qAsConst(excerpts)) { Score* nscore = new Score(e->oscore()); e->setPartScore(nscore); nscore->style().set(Sid::createMultiMeasureRests, true); @@ -8396,7 +8389,7 @@ bool MuseScore::saveScoreParts(const QString& inFilePath, const QString& outFile QJsonArray partsMetaList; QJsonArray partsTitles; - for (Excerpt* excerpt : score->excerpts()) { + for (Excerpt* excerpt : qAsConst(score->excerpts())) { Score* part = excerpt->partScore(); QMap partMetaTags = part->metaTags(); @@ -8493,7 +8486,7 @@ bool MuseScore::exportPartsPdfsToJSON(const QString& inFilePath, const QString& //if no parts, generate parts from existing instruments if (score->excerpts().size() == 0) { auto excerpts = Excerpt::createAllExcerpt(score); - for (Excerpt* e : excerpts) { + for (Excerpt* e : qAsConst(excerpts)) { Score* nscore = new Score(e->oscore()); e->setPartScore(nscore); nscore->style().set(Sid::createMultiMeasureRests, true); @@ -8507,7 +8500,7 @@ bool MuseScore::exportPartsPdfsToJSON(const QString& inFilePath, const QString& scores.append(score); QJsonArray partsArray; QJsonArray partsNamesArray; - for (Excerpt* e : score->excerpts()) { + for (Excerpt* e : qAsConst(score->excerpts())) { scores.append(e->partScore()); QJsonValue partNameVal(e->title()); partsNamesArray.append(partNameVal); diff --git a/mscore/scoreview.cpp b/mscore/scoreview.cpp index b346a6fd5ca2b..875abac76dbc9 100644 --- a/mscore/scoreview.cpp +++ b/mscore/scoreview.cpp @@ -53,7 +53,6 @@ #include "libmscore/navigate.h" #include "libmscore/notedot.h" #include "libmscore/note.h" -#include "libmscore/noteline.h" #include "libmscore/page.h" #include "libmscore/part.h" #include "libmscore/pitchspelling.h" @@ -244,7 +243,7 @@ void ScoreView::setScore(Score* s) _curLoopOut->move(s->pos(POS::RIGHT)); loopToggled(getAction("loop")->isChecked()); - connect(s, SIGNAL(posChanged(POS,unsigned)), SLOT(posChanged(POS,unsigned))); + connect(s, SIGNAL(posChanged(POS,uint)), SLOT(posChanged(POS,uint))); connect(this, SIGNAL(viewRectChanged()), this, SLOT(updateContinuousPanel())); } } @@ -1071,7 +1070,7 @@ void ScoreView::drawAnchorLines(QPainter& painter) const auto dropAnchorColor = preferences.getColor(PREF_UI_SCORE_VOICE4_COLOR); QPen pen(QBrush(dropAnchorColor), 2.0 / painter.worldTransform().m11(), Qt::DotLine); - for (const QLineF& anchor : m_dropAnchorLines) { + for (const QLineF& anchor : qAsConst(m_dropAnchorLines)) { painter.setPen(pen); painter.drawLine(anchor); @@ -1334,7 +1333,7 @@ void ScoreView::paint(const QRect& r, QPainter& p) } } else { - for (Page* page : _score->pages()) { + for (Page* page : qAsConst(_score->pages())) { QRectF pr(page->abbox().translated(page->pos())); if (pr.right() < fr.left()) continue; @@ -1361,7 +1360,7 @@ void ScoreView::paint(const QRect& r, QPainter& p) #ifndef NDEBUG if (!score()->printing()) { if (MScore::showSystemBoundingRect) { - for (const System* system : page->systems()) { + for (const System* system : qAsConst(page->systems())) { QPointF pt(system->ipos()); qreal h = system->height() + system->minBottom() + system->minTop(); p.translate(pt); @@ -1371,7 +1370,7 @@ void ScoreView::paint(const QRect& r, QPainter& p) } } if (MScore::showSegmentShapes) { - for (const System* system : page->systems()) { + for (const System* system : qAsConst(page->systems())) { for (const MeasureBase* mb : system->measures()) { if (mb->type() == ElementType::MEASURE) { const Measure* m = static_cast(mb); @@ -1391,7 +1390,7 @@ void ScoreView::paint(const QRect& r, QPainter& p) } } if (MScore::showSkylines) { - for (const System* system : page->systems()) { + for (const System* system : qAsConst(page->systems())) { for (SysStaff* ss : *system->staves()) { if (!ss->show()) continue; @@ -1410,7 +1409,7 @@ void ScoreView::paint(const QRect& r, QPainter& p) pen.setStyle(Qt::SolidLine); p.setPen(pen); p.setBrush(Qt::NoBrush); - for (const System* system : page->systems()) { + for (const System* system : qAsConst(page->systems())) { for (const MeasureBase* mb : system->measures()) { if (mb->type() == ElementType::MEASURE) { const Measure* m = static_cast(mb); @@ -1496,12 +1495,11 @@ void ScoreView::paint(const QRect& r, QPainter& p) // drag vertical start line p.drawLine(QLineF(x2, y1, x2, y2).translated(system2->page()->pos())); - System* system1 = system2; double x1; for (Segment* s = ss; s && (s != es); ) { Segment* ns = s->next1MMenabled(); - system1 = system2; + System* system1 = system2; system2 = s->measure()->system(); if (!system2) { // as before, use mmrest if necessary @@ -3183,7 +3181,7 @@ void ScoreView::startNoteEntry() if (s) lastSelected = s->nextChordRest(track, true); } - for (Element* e : el) { + for (Element* e : qAsConst(el)) { // loop through visible elements // looking for the CR in voice 1 with earliest tick and highest staff position // but stop if we find the last selected CR @@ -4817,7 +4815,7 @@ void ScoreView::cmdAddText(Tid tid, Tid customTid, PropertyFlags pf, Placement p Measure* m = s->findMeasure(); if (m && m->hasMMRest() && s->links()) { Measure* mmRest = m->mmRest(); - for (ScoreElement* se : *s->links()) { + for (ScoreElement* se : qAsConst(*s->links())) { TextBase* s1 = toTextBase(se); if (s != s1 && s1->findMeasure() == mmRest) { s = s1; @@ -5216,7 +5214,7 @@ QList ScoreView::elementsNear(QPointF p) for (int i = 0; i < MAX_FOOTERS; i++) if (score()->footerText(i) != nullptr) // gives the ability to select the footer el.push_back(score()->footerText(i)); - for (Element* e : el) { + for (Element* e : qAsConst(el)) { e->itemDiscovered = 0; if (!e->selectable() || e->isPage()) continue; @@ -5228,7 +5226,7 @@ QList ScoreView::elementsNear(QPointF p) // // if no relevant element hit, look nearby // - for (Element* e : el) { + for (Element* e : qAsConst(el)) { if (e->isPage() || !e->selectable()) continue; if (e->intersects(r)) @@ -5316,7 +5314,7 @@ void ScoreView::cmdMoveCR(bool left) e = e->parent(); QList crl; if (e->links()) { - for (ScoreElement* cr : *e->links()) + for (ScoreElement* cr : qAsConst(*e->links())) crl.append(static_cast(cr)); } else diff --git a/mscore/shortcut.cpp b/mscore/shortcut.cpp index fa6efb398ae64..58762f1bacd96 100644 --- a/mscore/shortcut.cpp +++ b/mscore/shortcut.cpp @@ -11,8 +11,8 @@ //============================================================================= #include "globals.h" -#include "shortcut.h" #include "icons.h" +#include "shortcut.h" #include "libmscore/xml.h" @@ -4443,7 +4443,7 @@ void Shortcut::retranslate() void Shortcut::refreshIcons() { - for (Shortcut* s : _shortcuts) { + for (Shortcut* s : qAsConst(_shortcuts)) { QAction* a = s->action(); if (a && s->icon() != Icons::Invalid_ICON) { a->setIcon(*icons[int(s->icon())]); @@ -4651,7 +4651,7 @@ static QList loadShortcuts(QString fileLocation) void Shortcut::loadFromNewFile(QString fileLocation) { QList list = loadShortcuts(fileLocation); - for (const Shortcut1& sc : list) { + for (const Shortcut1& sc : qAsConst(list)) { Shortcut* s = getShortcut(sc.key); if (s) { s->setKeys(sc.keys); @@ -4697,7 +4697,7 @@ QActionGroup* Shortcut::getActionGroupForWidget(MsWidget w, Qt::ShortcutContext void Shortcut::resetToDefault() { QList sl = loadShortcuts(defaultFileName); - for (const Shortcut1& sc : sl) { + for (const Shortcut1& sc : qAsConst(sl)) { Shortcut* s = getShortcut(sc.key); if (s) { s->setKeys(sc.keys); @@ -4741,7 +4741,7 @@ void Shortcut::reset() _standardKey = QKeySequence::UnknownKey; _keys.clear(); QList sl = loadShortcuts(defaultFileName); - for (const Shortcut1& sc : sl) { + for (const Shortcut1& sc : qAsConst(sl)) { if (sc.key == _key) { setKeys(sc.keys); setStandardKey(sc.standardKey); @@ -4791,12 +4791,13 @@ QKeySequence Shortcut::keySeqFromString(const QString& str, QKeySequence::Sequen for (i = 0; i < KEYSEQ_SIZE; ++i) code[i] = 0; - QStringList strList = str.split(QRegularExpression("(?